Hi,
I'm trying to do something like the indirect function on the sheets but on VBA. I have a variable that it's value is a String and it's the name of another variable and I'm trying to call the variable.
Ex.
Sub a()
Dim SM
Dim name
SM = 1
name = SM
msgbox("name")
End Sub
I'm expecting a message box with the value of the variable SM but I don't know how I can do this or if it is even possible.
Thanks,
juancamilo87
Sub a() Dim SM Dim name SM = 1 name = SM MsgBox name End Sub
This code will display a messagebox with the prompt = 1
Regards
I didn't know that work.
Actually what I'm needing is this.
Sub d()
dim name23
dim sm
name23 = 2
sm = "e23"
msgbox "nam"&"e23"
End sub
And I'm looking for the result 2.
Thanks![]()
maybe if you described the problem you are trying to solve, a solution would present itself.
The combining strings as variables names just doesn't sound like the real problem.
When using variables do not enclose them within "
msgbox name23 & sm
or
msgbox name23 + sm
or to put a space between the variables
msgbox name23 & " " & sm
Please Read Forum Rules Before Posting
Wrap VBA code by selecting the code and clicking the # icon or Read This
How To Cross Post politely
Top Excel links for beginners to Experts
If you are pleased with a member's answer then use the Scales icon to rate it
If my reply has assistedor failed to assist you
I welcome your Feedback.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks