Solved

Quickie !  How to refer to a Name in VBA

Posted on 2011-02-16
6
250 Views
Last Modified: 2012-05-11
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
Comment
Question by:Patrick O'Dea
6 Comments
 
LVL 50

Accepted Solution

by:
Ingeborg Hawighorst earned 333 total points
ID: 34911458
Hello,

Range.("initial")

cheers
0
 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
ID: 34911467
Or, to complete your code lines

dim strInitial as string
    strInitial = Range.("Initial")
0
 
LVL 50

Assisted Solution

by:Ingeborg Hawighorst
Ingeborg Hawighorst earned 333 total points
ID: 34911483
Sorry, not quite awake yet. no dot!!

Dim strInitial As String
    strInitial = Range("Initial")
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 33

Assisted Solution

by:jppinto
jppinto earned 167 total points
ID: 34911508
0
 

Author Closing Comment

by:Patrick O'Dea
ID: 34911543
Thanks all.
I said it was a quickie!

I will check the links out jppinto
0
 
LVL 45

Expert Comment

by:patrickab
ID: 34911839
This is much simpler and will also work:

dim strInitial as string
strInitial = [Initial]

The [] square brackets just mean evaluate.

Patrick
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question