Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Ant
 
Posts: n/a
Default Looking for code to define a range

I am looking for code that automatically defines/names a range which changes
each month. Also I need the code which identifies the location of the last
cell in the range.
  #2   Report Post  
Otto Moehrbach
 
Posts: n/a
Default

Not knowing what your range looks like I'll assume you want a range starting
at A1 and going down to the last occupied cell in Column A. I'll also
assume you want to name this range "MyRange".
To define and name the range, use:
Range("A1", Range("A" & Rows.Count).End(xlUp)).Name = "MyRange"
The cell address of the last occupied cell in Column A is:
Range("A" & Rows.Count).Address
If you want to use the range name in identifying the last cell of the range,
use:
Range("MyRange")(Range("MyRange").Count).Address
HTH Otto
"Ant" wrote in message
...
I am looking for code that automatically defines/names a range which
changes
each month. Also I need the code which identifies the location of the last
cell in the range.



  #3   Report Post  
Ant
 
Posts: n/a
Default

Thanks Otto. That works well. If my range goes across to say column H, how do
I incorporate this into the formula below. I tried Range("A1", Range("A1:H1"
& Rows... but it debugged.

"Otto Moehrbach" wrote:

Not knowing what your range looks like I'll assume you want a range starting
at A1 and going down to the last occupied cell in Column A. I'll also
assume you want to name this range "MyRange".
To define and name the range, use:
Range("A1", Range("A" & Rows.Count).End(xlUp)).Name = "MyRange"
The cell address of the last occupied cell in Column A is:
Range("A" & Rows.Count).Address
If you want to use the range name in identifying the last cell of the range,
use:
Range("MyRange")(Range("MyRange").Count).Address
HTH Otto
"Ant" wrote in message
...
I am looking for code that automatically defines/names a range which
changes
each month. Also I need the code which identifies the location of the last
cell in the range.




  #4   Report Post  
Otto Moehrbach
 
Posts: n/a
Default

Range("A1", Range("H" & Rows.Count).End(xlUp)).Name = "MyRange"
HTH Otto
"Ant" wrote in message
...
Thanks Otto. That works well. If my range goes across to say column H, how
do
I incorporate this into the formula below. I tried Range("A1",
Range("A1:H1"
& Rows... but it debugged.

"Otto Moehrbach" wrote:

Not knowing what your range looks like I'll assume you want a range
starting
at A1 and going down to the last occupied cell in Column A. I'll also
assume you want to name this range "MyRange".
To define and name the range, use:
Range("A1", Range("A" & Rows.Count).End(xlUp)).Name = "MyRange"
The cell address of the last occupied cell in Column A is:
Range("A" & Rows.Count).Address
If you want to use the range name in identifying the last cell of the
range,
use:
Range("MyRange")(Range("MyRange").Count).Address
HTH Otto
"Ant" wrote in message
...
I am looking for code that automatically defines/names a range which
changes
each month. Also I need the code which identifies the location of the
last
cell in the range.






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
Help PLEASE! Not sure what answer is: Match? Index? Other? baz Excel Worksheet Functions 7 September 3rd 05 03:47 PM
Define range for graphs/charts with validation list janfolmer Excel Discussion (Misc queries) 2 August 29th 05 02:02 PM
Macro - define cell range for a sum function Fad Excel Discussion (Misc queries) 2 June 6th 05 12:40 PM
Define a range based on another named range Basil Excel Worksheet Functions 2 February 21st 05 01:47 PM
Define Range with an offset GregR Excel Discussion (Misc queries) 9 December 21st 04 07:22 AM


All times are GMT +1. The time now is 06:04 PM.

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

About Us

"It's about Microsoft Excel"