#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default Name Issue

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.programming
external usenet poster
 
Posts: 11,058
Default Name Issue

Dim clara as String
clara="A2:A500"
For Each t In Sheets("Tasks").Range(clara)
--
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.programming
external usenet poster
 
Posts: 252
Default Name Issue

Hi Gary,
thank you for your help
--
thank you so much for your help


"Gary''s Student" wrote:

Dim clara as String
clara="A2:A500"
For Each t In Sheets("Tasks").Range(clara)
--
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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Name Issue

Here is one way:

Sub fh()
Sheets(1).Range("B2:B5").Name = "SomeName"
End Sub

You can also just use a variable for code purposes:

SomeName = Range("B2:B5")

The difference is that when you use the range name as the object it would be
Range("SomeName") and is a range object. The other would be a variable that
could be used as a value - SomeName - or a range - SomeName.Address and a few
other variations depending on your declarations.

"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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default Name Issue

Hi JLGWhiz

thank you for your help

Clara
--
thank you so much for your help


"JLGWhiz" wrote:

Here is one way:

Sub fh()
Sheets(1).Range("B2:B5").Name = "SomeName"
End Sub

You can also just use a variable for code purposes:

SomeName = Range("B2:B5")

The difference is that when you use the range name as the object it would be
Range("SomeName") and is a range object. The other would be a variable that
could be used as a value - SomeName - or a range - SomeName.Address and a few
other variations depending on your declarations.

"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



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
Value issue Patrick C. Simonds Excel Programming 7 October 27th 07 04:28 PM
Msg Box VBA Issue CJLuke Excel Programming 8 January 26th 07 06:48 PM
For Next Issue darkman Excel Programming 5 May 24th 06 08:40 AM
Sub name issue Robert Hargreaves[_2_] Excel Programming 6 June 6th 05 04:47 PM
With and End With issue Pat Excel Programming 4 May 3rd 05 10:20 PM


All times are GMT +1. The time now is 10:32 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"