View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz[_2_] JLGWhiz[_2_] is offline
external usenet poster
 
Posts: 1,565
Default Indirectly referring to a variable

I am not clear on what you are after, but if you place a variable inside
quote marks, it becomes a string and the value is what you see. e.g. If the
variable Snow = 25, when you place it inside quotes then "Snow" = "Snow".
So, if you want the values of Snow and Shoe to be added it would be
VariableWant = Snow + Shoe to get VariableWant to equal the sum of Snow +
Shoe. Then you could add NumberNeed = 5 + VariableWant and get a numeric
value. But if you use quotes around the variables, the all you get is
concatenated strings.


"ZipCurs" wrote in message
...
Hello,

This is probably easy ... or impossible, but I cannot figure out how to do
this. I want to assembly a variable name in code, and then get that
variable. Separate parts of my macro tell me my prefix is "Snow" and my
suffix is "Shoe". How to I get the value of "SnowShoe"? I have a lot of
these variables. The following does not work:

VariableIWant="Snow" & "Shoe"
NumberINeed=5+VariableIWant

I ended up with a bunch of If statements. Effective but not too elegant.
Any help would be appreciated. Thank you in advance.