jrobin5881
Technical User
Good Morning,
I have a userform with multiple textboxes and a "Submit" command button below. I want the user to add values, text to the textboxes and have the data post to a master sheet when they're done. I know how to do this with one textbox at a time however I'm trying to streamline the code to loop through all the textboxes and complete the task in one shot.
My textboxes are named "txt2045, txt2046.... txtbox20413". The .text will begin at row 4 in sheet29 in column 4 and end at row 13.
I set up a For Next loop using "t" as the variable for the remainder of textbox name and "i" as the variable for the row number.
The code does not like me using "t" as the remainder of the textbox name. What am i doing wrong?
SAMPLE
I have a userform with multiple textboxes and a "Submit" command button below. I want the user to add values, text to the textboxes and have the data post to a master sheet when they're done. I know how to do this with one textbox at a time however I'm trying to streamline the code to loop through all the textboxes and complete the task in one shot.
My textboxes are named "txt2045, txt2046.... txtbox20413". The .text will begin at row 4 in sheet29 in column 4 and end at row 13.
I set up a For Next loop using "t" as the variable for the remainder of textbox name and "i" as the variable for the row number.
The code does not like me using "t" as the remainder of the textbox name. What am i doing wrong?
SAMPLE
Code:
Private Sub CommandButton6_Click()
Dim t As Integer
Dim i As Integer
For t = 5 To 14
i = 4
Sheet29.Select
Cells(i, 4) = txt204 & t & .Text
i = i + 1
Next
End Sub