Reputation: 14547
I have created few Constants (VBA identifiers declared with the key word Const
) that look like Rg_Euro
, Rg_Usd
, Rg_Cad
, ... to define specific regions into my workbook.
As I have these "extensions" (Euro
, Usd
, Cad
, ...) in the DataBase that I'm working with, I tried to get the values of my constant by creating a string like this : Str = "Rg_" & extension(i)
But I can't seem to find a workaround to call the Constant and get its value from it... I'm googled it but didn't found what I was looking for and I'm starting to think that it might not be possible directly...
I thought of a User Defined Function with a Select Case
on the String to return the right value, but it is just going to add another function, so I'm looking for a more direct solution if there is one!
Upvotes: 0
Views: 2467
Reputation: 3311
I'm not a pro and my answer it's only what I've done to solve a similar problem, anyway, I hope it helps:
You can add controls (for example Textbox) named as your constants and set the value you need, then you'll be able to catch any value with this:
Me.Controls("RG_" & extension(i)).text
Upvotes: 1