Cell value to get variable value

mikeymay

Well-known Member
Joined
Jan 17, 2006
Messages
1,632
Office Version
  1. 365
Platform
  1. Windows
I have a number of String variables
strCustomer
StrAddress1
etc

These are defined via a UF and I want to use a list of the variable names to get the variable value

E.g.
B1 to show the strCustomer variable value where A1 contains the string strCustomer
B2 to show the strAddress1 variable value where A2 contains the string strAddress1

I thought using some thing like the following would work
VBA Code:
Range("B1") = Variable(range("A1"))

The code to add the variable values to the worksheet take place outside the UF code after the UF has been unloaded.

TIA
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
That won't work unless you load the variables into a dictionary using the key as the variable name, or use a class with properties for each variable. Why would you want to do this?
 
Upvote 0
I am trying to keep code down to a minimum so looping through a list of the variable 'names' to get a value is tidier than having IF statements with lots of ANDs.

Basically, the UF holds customer details and rather than checking if the customer name, address 1, city and postcode added, I want to loop through and if the string is flagged as required, it checks there is a value assigned to the string.

Not a biggie if it's not possible though but I thought as you can do this with UF controls, you might be able to do it with variables.
 
Upvote 0
It sounds like you should be using a class to me and putting the validation code in there.
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,318
Members
452,634
Latest member
cpostell

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