• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

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"
0
Patrick O'Dea
Asked:
Patrick O'Dea
3 Solutions
 
Ingeborg Hawighorst (Microsoft MVP / EE MVE)Microsoft MVP ExcelCommented:
Hello,

Range.("initial")

cheers
0
 
Ingeborg Hawighorst (Microsoft MVP / EE MVE)Microsoft MVP ExcelCommented:
Or, to complete your code lines

dim strInitial as string
    strInitial = Range.("Initial")
0
 
Ingeborg Hawighorst (Microsoft MVP / EE MVE)Microsoft MVP ExcelCommented:
Sorry, not quite awake yet. no dot!!

Dim strInitial As String
    strInitial = Range("Initial")
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
jppintoCommented:
0
 
Patrick O'DeaAuthor Commented:
Thanks all.
I said it was a quickie!

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

dim strInitial as string
strInitial = [Initial]

The [] square brackets just mean evaluate.

Patrick
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now