LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Evaluate a Variable Name from a String

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.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to evaluate string? Boban Excel Programming 4 November 4th 05 06:21 PM
Evaluate and execute a string Randall[_6_] Excel Programming 3 August 4th 05 05:19 PM
Evaluate string as a formula peacelittleone Excel Worksheet Functions 3 June 26th 05 06:20 PM
Evaluate using a variable - Help please SA3214 Excel Programming 11 April 11th 05 10:38 PM
how to evaluate the content of a string as if it was a formula cyrille de brébisson Excel Discussion (Misc queries) 5 December 6th 04 10:47 PM


All times are GMT +1. The time now is 04:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"