Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Lucas Ward   on Oct 03 In MS Office Category.

  
Question Answered By: Anselma Schmidt   on Oct 03

The problem is:
when a user  selects more than one line  in a textbox, how do I have the macro
run code on each line.

tb_Data is the textbox  with the data.

I've look at:
sub GetSelection
'Need to loop thur only selected  rows
'Only gives the last row selected
'(however, if nothing is selected the
'value is 0 which is the first line
'which isn't good)
SelectionRow = UserForm2.tb_Data.ListIndex

While SelectionRow > -1
'Get data from the 1st column
Column1 = UserForm2.tb_Data.List(SelectionRow)
'Get data from the 2nd column
Column2 = UserForm2.tb_Data.List(SelectionRow, 1)

' Call MyMacro(Column1, Column2)

SelectionRow = SelectionRow - 1
Wend

'If I could deselect the current last row I could
'loop backwards and run  MyMacro only on all
'selected lines

end sub

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on textbox on a form Or get search suggestion and latest updates.


Tagged: