Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Macro to select a variable range

I am creating a macro that will select a range of cells and use them as a
series in a chart. The range of cells will always be bewteen a cell
containing the string "Temperature" and the next blank cell. The location of
this range however, is not fixed.

I can write the code to find the cell containing the string "Temperature"
and move one cell down but cannot work out how to select the range from here
to the cell above the next blank cell.

All help is greatly appreciated,
Amy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default Macro to select a variable range

If the cell containing the string "Temperature" is the active cell then the
row No of the cell above the next blank cell is

rngendrow = ActiveCell.End(xlDown).Row

Regards,
Stefi

€˛AmyHomewood€¯ ezt Ć*rta:

I am creating a macro that will select a range of cells and use them as a
series in a chart. The range of cells will always be bewteen a cell
containing the string "Temperature" and the next blank cell. The location of
this range however, is not fixed.

I can write the code to find the cell containing the string "Temperature"
and move one cell down but cannot work out how to select the range from here
to the cell above the next blank cell.

All help is greatly appreciated,
Amy

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Macro to select a variable range

Hi Stefi,

Thanks for the quick response but unfortunately rngendrow doesn't give what
I'm after. rngendrow gives row 561 which is the last row containing data in
the whole sheet, which happens to be D561 not the last cell above the next
blank cell of column A which is the column containing the range I am
interested in.

For this particular set of data the range I want is A202:A241, but I want to
be able to select the range bewteen the specified points (between cell
containing the string "Temperature" and cell above next blank cell) no matter
where they are in the sheet.

Amy

"Stefi" wrote:

If the cell containing the string "Temperature" is the active cell then the
row No of the cell above the next blank cell is

rngendrow = ActiveCell.End(xlDown).Row

Regards,
Stefi

€˛AmyHomewood€¯ ezt Ć*rta:

I am creating a macro that will select a range of cells and use them as a
series in a chart. The range of cells will always be bewteen a cell
containing the string "Temperature" and the next blank cell. The location of
this range however, is not fixed.

I can write the code to find the cell containing the string "Temperature"
and move one cell down but cannot work out how to select the range from here
to the cell above the next blank cell.

All help is greatly appreciated,
Amy

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default Macro to select a variable range

I suppose that your data structure is something like this:

The cell containing the string "Temperature" is A202
There are Temperature data from A202 to A241
A242 is blank

In this case

range("A202").End(xlDown).Row
returns 241

Post if this is not the case!

Stefi

€˛AmyHomewood€¯ ezt Ć*rta:

Hi Stefi,

Thanks for the quick response but unfortunately rngendrow doesn't give what
I'm after. rngendrow gives row 561 which is the last row containing data in
the whole sheet, which happens to be D561 not the last cell above the next
blank cell of column A which is the column containing the range I am
interested in.

For this particular set of data the range I want is A202:A241, but I want to
be able to select the range bewteen the specified points (between cell
containing the string "Temperature" and cell above next blank cell) no matter
where they are in the sheet.

Amy

"Stefi" wrote:

If the cell containing the string "Temperature" is the active cell then the
row No of the cell above the next blank cell is

rngendrow = ActiveCell.End(xlDown).Row

Regards,
Stefi

€˛AmyHomewood€¯ ezt Ć*rta:

I am creating a macro that will select a range of cells and use them as a
series in a chart. The range of cells will always be bewteen a cell
containing the string "Temperature" and the next blank cell. The location of
this range however, is not fixed.

I can write the code to find the cell containing the string "Temperature"
and move one cell down but cannot work out how to select the range from here
to the cell above the next blank cell.

All help is greatly appreciated,
Amy

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Macro to select a variable range

The data is as you said but columns C and D also have data which runs down to
row 561. The code you gave in the last post is coming up with an error saying
incorrect use of the row command.

I have however managed to perform the task I was after. Thanks again for
your responses
Amy

"Stefi" wrote:

I suppose that your data structure is something like this:

The cell containing the string "Temperature" is A202
There are Temperature data from A202 to A241
A242 is blank

In this case

range("A202").End(xlDown).Row
returns 241

Post if this is not the case!

Stefi

€˛AmyHomewood€¯ ezt Ć*rta:

Hi Stefi,

Thanks for the quick response but unfortunately rngendrow doesn't give what
I'm after. rngendrow gives row 561 which is the last row containing data in
the whole sheet, which happens to be D561 not the last cell above the next
blank cell of column A which is the column containing the range I am
interested in.

For this particular set of data the range I want is A202:A241, but I want to
be able to select the range bewteen the specified points (between cell
containing the string "Temperature" and cell above next blank cell) no matter
where they are in the sheet.

Amy

"Stefi" wrote:

If the cell containing the string "Temperature" is the active cell then the
row No of the cell above the next blank cell is

rngendrow = ActiveCell.End(xlDown).Row

Regards,
Stefi

€˛AmyHomewood€¯ ezt Ć*rta:

I am creating a macro that will select a range of cells and use them as a
series in a chart. The range of cells will always be bewteen a cell
containing the string "Temperature" and the next blank cell. The location of
this range however, is not fixed.

I can write the code to find the cell containing the string "Temperature"
and move one cell down but cannot work out how to select the range from here
to the cell above the next blank cell.

All help is greatly appreciated,
Amy



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default Macro to select a variable range

Yes, because the whola command is

rngendrow = range("A202").End(xlDown).Row

If you want to apply it to column C then

rngendrow = range("C202").End(xlDown).Row

Stefi

€˛AmyHomewood€¯ ezt Ć*rta:

The data is as you said but columns C and D also have data which runs down to
row 561. The code you gave in the last post is coming up with an error saying
incorrect use of the row command.

I have however managed to perform the task I was after. Thanks again for
your responses
Amy

"Stefi" wrote:

I suppose that your data structure is something like this:

The cell containing the string "Temperature" is A202
There are Temperature data from A202 to A241
A242 is blank

In this case

range("A202").End(xlDown).Row
returns 241

Post if this is not the case!

Stefi

€˛AmyHomewood€¯ ezt Ć*rta:

Hi Stefi,

Thanks for the quick response but unfortunately rngendrow doesn't give what
I'm after. rngendrow gives row 561 which is the last row containing data in
the whole sheet, which happens to be D561 not the last cell above the next
blank cell of column A which is the column containing the range I am
interested in.

For this particular set of data the range I want is A202:A241, but I want to
be able to select the range bewteen the specified points (between cell
containing the string "Temperature" and cell above next blank cell) no matter
where they are in the sheet.

Amy

"Stefi" wrote:

If the cell containing the string "Temperature" is the active cell then the
row No of the cell above the next blank cell is

rngendrow = ActiveCell.End(xlDown).Row

Regards,
Stefi

€˛AmyHomewood€¯ ezt Ć*rta:

I am creating a macro that will select a range of cells and use them as a
series in a chart. The range of cells will always be bewteen a cell
containing the string "Temperature" and the next blank cell. The location of
this range however, is not fixed.

I can write the code to find the cell containing the string "Temperature"
and move one cell down but cannot work out how to select the range from here
to the cell above the next blank cell.

All help is greatly appreciated,
Amy

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
Macro to select a variable range Elmtree Excel Programming 9 August 30th 08 02:40 AM
Select variable range ewan7279 Excel Programming 1 September 5th 07 09:46 AM
Select a variable range Eduardo Excel Programming 7 August 8th 07 01:46 PM
Use a Variable to select a range Connie Excel Discussion (Misc queries) 3 October 19th 06 05:48 PM
select a variable range evil baby[_15_] Excel Programming 4 March 8th 06 08:38 PM


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