How to refer a name in VBA

C

clara

Hi all,

the following is my current code:
For Each t In Sheets("Tasks").Range("A2:A500")

I'd like to define a name refer to ("A2:A500") and use that name in the
above code, how can I do it.

Clara
 
G

Gary''s Student

Dim S as String
S="A2:A500"

and then use:
Range(S)

you can accomplish the same thing by using a Defined Name from the worksheet.
 
D

Don Guillett

Sheets("Tasks").Range("A2:A500").name="usethis"

for each t in [usethis]
'blah
next t
 
C

clara

Hi Don,

Thank you for your help

Clara
--
thank you so much for your help


Don Guillett said:
Sheets("Tasks").Range("A2:A500").name="usethis"

for each t in [usethis]
'blah
next t


--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
clara said:
Hi all,

the following is my current code:
For Each t In Sheets("Tasks").Range("A2:A500")

I'd like to define a name refer to ("A2:A500") and use that name in the
above code, how can I do it.

Clara
 
D

Don Guillett

Glad to help

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
clara said:
Hi Don,

Thank you for your help

Clara
--
thank you so much for your help


Don Guillett said:
Sheets("Tasks").Range("A2:A500").name="usethis"

for each t in [usethis]
'blah
next t


--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
clara said:
Hi all,

the following is my current code:
For Each t In Sheets("Tasks").Range("A2:A500")

I'd like to define a name refer to ("A2:A500") and use that name in the
above code, how can I do it.

Clara
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top