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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

lozzablake

Well-known Member
Joined
Dec 15, 2005
Messages
818
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
 

Oorang

Well-known Member
Joined
Mar 4, 2005
Messages
2,071
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.
 

Forum statistics

Threads
1,141,096
Messages
5,704,312
Members
421,338
Latest member
Pepess

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
Top