[VBA] Variable from Names

skorpionkz

Well-known Member
Joined
Oct 1, 2013
Messages
1,171
Office Version
  1. 2016
Hi guys,

I have Name (let say myName) that I am adding value (let say myValue). This is not the range, I want it to hold the value itself (which is name of another workbook for later use in VBA). In the name manager myName shows correct value, but when in VBA I am trying to assign myName.value to the variable, instead of having "myValue" i am getting "="myValue"", therefore it crashes further code.

Any idea, how to get around it?

Thank you
 
Last edited:

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Presuming its a single cell named range you need:

Code:
Range("myName").Value
 
Upvote 0
You could use Evaluate like this:

Code:
Evaluate("myName")

or just:

Code:
[myName]
 
Upvote 0
You could use Evaluate like this:

Code:
Evaluate("myName")

or just:

Code:
[myName]

[myName] didn't work, but Evaluate did the trick. I got brain lock and forgot about Evaluate :)

Thank you.
 
Upvote 0

Forum statistics

Threads
1,215,359
Messages
6,124,488
Members
449,165
Latest member
ChipDude83

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