I see this a LOT in here... and everytime, people don't quite get what the poster is asking for.... mainly because it's not possible. You can't create a variable to hold a variable's name and expect to get the variable's value.
Going back to the OP's original code, I'll make a change, then state what I think the OP is looking for, and see if I've got it right.
I'm guessing that in this case the OP would expect "Hack" in the first message box and "TechGnome" in the second box.Code:Dim str1 As String Dim str2 As String str1 = "Hack" str2 = "TechGnome" For i = 1 To 2 Set obj= "Str" & 1 MsgBox obj Next i
Yeah, it doesn't work that way. What you would get is "Str1" followed by "Str2"... not quite what you are looking for is it?
There are ways to accomplish what you are doing, but not in the simplistic manner that you want - hint: Arrays, collections.
-tg




Reply With Quote