Hi,
I have a form containing a single combo box and 50 text boxes, names textbox1, textbox2....textbox50.
Using the combo box I want to populate the textboxes with the results of a vlookup:
textbox1 = Application.WorksheetFunction.VLookup(GeneratorComboBox.Value, Sheets(1).Range("A1:AY570"), 1, False)
textbox2 = Application.WorksheetFunction.VLookup(GeneratorComboBox.Value, Sheets(1).Range("A1:AY570"), 2, False)
textbox3 = Application.WorksheetFunction.VLookup(GeneratorComboBox.Value, Sheets(1).Range("A1:AY570"), 3, False)
etc.
How can i store the textbox name in an array and then just loop through the array using a single textbox statment?
I had tried to use this: But found out that textboxes are not necessarily stored sequentially as Me.Control objects
Dim ctl As Control
Dim k as integer
k = 0
For Each ctl In Me.Controls
If TypeOf ctl Is MSForms.TextBox Then
Me.Controls(k).Value = Application.WorksheetFunction.VLookup(GeneratorComboBox.Value, Sheets(1).Range("A1:AY50"), k, False)
End If
k = k + 1
Next
I've looked high and low for any infomartion on processing textboxes in arrays without luck.
Any help would be appreciated.
Thanks!
Bookmarks