Returning Global variables values via UDF

Boomer67

New Member
Joined
Jan 20, 2005
Messages
16
I have a sheet with numerous Global variables declared in VBA with part of the name determined by a tenor, e.g. Pillar3m, Pillar6m, etc. I would like to use a UDF to be able to return these values based on the tenor. So if I ask for "3m" I get the Pillar3m value etc. I cannot seem to work out a means to be able to concatenate the value. For example
Code:
Application.Evaluate("Pillar" & tenor)
Does not work. Is it possible, and if so, how?
Thanks
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
You either need to make the variables members of a class (so you can use CallByName) or you need to load them into a Dictionary or Collection so that you can access them with a key.
 
Upvote 0
You either need to make the variables members of a class (so you can use CallByName) or you need to load them into a Dictionary or Collection so that you can access them with a key.

Thanks Rory. Let me take a look at CallBYName and see if that works. I suspect loading into a collection isn't going to be much of a saving. Thanks.
 
Upvote 0
Kenneth, I have considered that. As most of the time I need the variables in VBA I am trying to avoid the overheads of the Excel / VBA exchanges.
 
Upvote 0

Forum statistics

Threads
1,215,463
Messages
6,124,963
Members
449,200
Latest member
indiansth

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