1

Brand new to stackoverflow and am also quite new to programming. I am very grateful for this incredible resource. Thank you!
I have 30 TextBoxes on my Userform. TextBox1 TextBox2......TextBox30. I would like to assign values to all of them quickly using a For Next Loop. Just not too sure how. Example:

For X=1 to 30
   TextBox & X.Value ="Hello"
Next X

Thank you in advance for any help.

2 Answers 2

1

This should do it.

Private Sub UserForm_Initialize()
    For x = 1 To 30
        Controls("Textbox" & x).Value = "Hello " & x
    Next x
End Sub
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so much for your help. This certainly worked. Have a great day.
Mark it as the answer
0

How about this:

For x = 1 To 30
  Sheets(1).Shapes("textbox " & x).TextFrame.Characters.Text = "Hello"
Next x

1 Comment

The textboxes are in a userform, not on the worksheet

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.