Reputation: 361
I have a userform with several rows of textboxes. As I loop through the controls, I'm concatenating the textbox values for a final string. Rather than looping through every textbox, I am only looping through the first textbox in the row and trying to assign a value to a variable with the replace
method.
What I've tried: TBvalue = Replace(ctl.Name, "Textbox1", "Textbox2")
followed by
TBvalue2 = OnboardingLogForm.TBvalue.value
Also tried: TBvalue = OnboardingLogForm.Textbox & i.value
when iterating with i
How can I get the values of other textboxes without statically referring to them?
Upvotes: 0
Views: 179
Reputation: 361
Found an answer. Thanks for your help.
Me.Controls("TextBox" & i).value
Or, if there's any number order to your control names, you can try:
For Each ctl In Userform1.MultiPage1.Pages(0).Controls
blah = Me.Controls(Replace(ctl.Name, "TextBox1", "TextBox2")).value
Next
Upvotes: 1