' I want to loop through TextBoxes and get their values
' In this simple test case, to insert them in spreadsheet cells A1 and A2
' VBA does nor recognize a string as a Textbox name and I have not been
' able to find a way to make this work.
' Any help would be very much appreciated!
Sub Test()
Dim iCount As Integer
Dim strRange As String
Dim strTextBoxName As String
For iCount = 1 To 2
strRange = "A" & CStr(iCount)
strTextBoxName = "TextBox" & CStr(iCount)
MsgBox ("strTextBoxName = " & strTextBoxName) 'check whether name is correct
Range(strRange).Value = strTextBoxName.Value
' "Range(strRange).Value" works
' "strTextBoxName.Value" does not work (I have tried a few variations)
' I need to convert the string "strTextBoxName" to a format which VBA recognises as a TextBox name.
Next iCount
End Sub
Bookmarks