G
Guest
Is it possible in VBA to determine a variable name from a string? For
example -
- - - - - -
Dim VariableName as String
Dim FavoriteNumber as Integer
FavoriteNumber = 55
VariableName = "FavoriteNumber"
msgbox {*}
- - - - - -
* indicating an expression that will return the value of the FavoriteNumber
variable, using the value of VariableName ("FavoriteColor") to evaluate the
FavoriteColor variable, and return the value of 55.
I know the example seems overly complicated (why not just use the
FavoriteNumber directly in the code?)
I have a class module with 65 variables, and I would like to place a
reference to them all in an Array, so that I can loop through them all and
assign values, yet I would like the values to still be updated if any of the
variables are updated outside of the array.
In other words, I would like an object or expression that references a
variable.
example -
- - - - - -
Dim VariableName as String
Dim FavoriteNumber as Integer
FavoriteNumber = 55
VariableName = "FavoriteNumber"
msgbox {*}
- - - - - -
* indicating an expression that will return the value of the FavoriteNumber
variable, using the value of VariableName ("FavoriteColor") to evaluate the
FavoriteColor variable, and return the value of 55.
I know the example seems overly complicated (why not just use the
FavoriteNumber directly in the code?)
I have a class module with 65 variables, and I would like to place a
reference to them all in an Array, so that I can loop through them all and
assign values, yet I would like the values to still be updated if any of the
variables are updated outside of the array.
In other words, I would like an object or expression that references a
variable.