0

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?

1

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.