Can I use a subscript as part of a VBA variable name ?
Posted on 2013-09-22
This is the scenario.
I have a User form with 6 text boxes named as follows :
I am looping through a worksheet range and, depending on the value, populating the above text boxes until all 6 have been filled or until I come to the end of the range.
Rather than populating each text box specifically by name (eg teInvoiceNo4 = ) is it possible to create a loop using the loop index as the suffix digit of the text box name.
As an example, where i is the loop counter for the worksheet range (SalesArray), and x is the suffix digit of the 6 text box names, I tried the following...
Dim x as Long
Dim i as Long
For x = 1 to 100
If teOrderNo = SalesOrderNo Then
"teInvoiceNo" & i = SalesArray(x, 1)
But it complained about the syntax.