zendog1960
Active Member
- Joined
- Sep 27, 2003
- Messages
- 459
- Office Version
- 2019
- Platform
- Windows
I am creating a user form in which there are going to be 30+ textboxes. After copy pasting a few in, deleting a few, then adding more in, the numbering of these boxes are all over the place. I am doing a routine to populate these textboxes with values from a sheet within the workbook. I am using the following code:
<Code>
Dim i As Integer
For i = 1 To 32
Me.Controls("TextBox" & i).Value = Sheet1.Range("P" & i + 2).Value
Next i
</Code>
With the textbox numbers into the 40s, there are some that no longer exist, i.e. say TextBox17 was deleted.
My question: is there a way to renumber these textboxes so they are again sequential? It would make the code run better I think!
<Code>
Dim i As Integer
For i = 1 To 32
Me.Controls("TextBox" & i).Value = Sheet1.Range("P" & i + 2).Value
Next i
</Code>
With the textbox numbers into the 40s, there are some that no longer exist, i.e. say TextBox17 was deleted.
My question: is there a way to renumber these textboxes so they are again sequential? It would make the code run better I think!