ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How to refer a name in VBA (https://www.excelbanter.com/excel-discussion-misc-queries/192569-how-refer-name-vba.html)

clara

How to refer a name in VBA
 
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
--
thank you so much for your help

Gary''s Student

How to refer a name in VBA
 

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.
--
Gary''s Student - gsnu200793


"clara" wrote:

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
--
thank you so much for your help


Don Guillett

How to refer a name in VBA
 
Sheets("Tasks").Range("A2:A500").name="usethis"

for each t in [usethis]
'blah
next t


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"clara" wrote in message
...
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
--
thank you so much for your help



clara

How to refer a name in VBA
 
Hi Don,

Thank you for your help

Clara
--
thank you so much for your help


"Don Guillett" wrote:

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

for each t in [usethis]
'blah
next t


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"clara" wrote in message
...
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
--
thank you so much for your help




Don Guillett

How to refer a name in VBA
 
Glad to help

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"clara" wrote in message
...
Hi Don,

Thank you for your help

Clara
--
thank you so much for your help


"Don Guillett" wrote:

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

for each t in [usethis]
'blah
next t


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"clara" wrote in message
...
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
--
thank you so much for your help






All times are GMT +1. The time now is 08:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com