VBA question

Oorang

Well-known Member
Joined
Mar 4, 2005
Messages
2,071
Is there a way in VBA to indirectly reference a variable? Like an Eval type method? here is an example of what I was hoping for... but I wanted it to work with objects as well:
Code:
Dim T1 as String
Dim T2 as String
Dim T3 as String
Dim X as Byte
For X = 1 to 3
MsgBox Eval("T"&X)
Next X
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
I ususally end up setting up an array and using the array elements instead.

eg

Dim arryString (1 to 3) as String

and then

msgbox arryString(x)

Would be useful if there was a function
 
Upvote 0
Appreciate the response. That would be effective in the example I gave, but what I was actaully doing is making a function that identified the object type by trying to bind a variaty of explicityly declared objects to a generic object variable and then returning the type. For this to work of course I need to have quote a few explicitly declared variables. What I was looking for was a way to loop through them.
 
Upvote 0

Forum statistics

Threads
1,221,383
Messages
6,159,539
Members
451,571
Latest member
Qwissy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top