Link to home
Start Free TrialLog in
Avatar of Patrick O'Dea
Patrick O'DeaFlag for Ireland

asked on

Quickie ! How to refer to a Name in VBA

Example: This is very easy ... if I explain it correctly!

I have a value "J" stored in cell A1. (This value will change!)
I then define a NAME so that cell A1 is named "Initial"

In VBA code I want to set strInitial =   the value in name "Initial"
See below.  

dim strInitial as string
    strInitial = ?????

What is the correct syntax so that strInitial will hold the value of "Initial"
ASKER CERTIFIED SOLUTION
Avatar of Ingeborg Hawighorst (Microsoft MVP / EE MVE)
Ingeborg Hawighorst (Microsoft MVP / EE MVE)
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Or, to complete your code lines

dim strInitial as string
    strInitial = Range.("Initial")
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Patrick O'Dea

ASKER

Thanks all.
I said it was a quickie!

I will check the links out jppinto
This is much simpler and will also work:

dim strInitial as string
strInitial = [Initial]

The [] square brackets just mean evaluate.

Patrick