Textboxes as an array

  • Thread starter Thread starter sue
  • Start date Start date
S

sue

Is it possible to use textboxes as an array by some naming convention as with radio buttons? I have
a userForm that has 5 textboxes that would be easiest accessed in an array


TIA,

Susan
 
Susan,

VBA doesn't support arrays of objects, but you can use a naming convention
that achieves the same end result.

Name your textboxes TextBox1, TextBox2, etc. Then, in your code for a
commandbutton on the same userform:

Dim i As Integer
For i = 1 To 4
MsgBox Me.Controls("Textbox" & i).Text
Next i

HTH,
Bernie
MS Excel MVP
 
Back
Top