Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 252
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default 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


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 252
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Refer to value strikeuk Excel Discussion (Misc queries) 8 May 17th 06 08:42 AM
refer to columns Cindy Excel Discussion (Misc queries) 1 January 20th 06 09:51 PM
refer JE McGimpsey Excel Discussion (Misc queries) 2 November 28th 05 06:55 PM
How to refer to every 5 th cell? R.P.McMurphy Excel Discussion (Misc queries) 21 August 27th 05 06:13 PM
refer to other xls file DKY Excel Worksheet Functions 1 November 19th 04 08:02 PM


All times are GMT +1. The time now is 01:43 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"