Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Dynamic Cell Selection

I'm looking for a way to dynamically select a range of cells.

I have a spreadsheet in which the number of rows and the number of columns
changes from time to time. By using the Count Worsheet function, I can
determine the number of rows and the number of columns is selected from an
array of values. I want to be able to select and copy a subset of the total
number of cells contained in the Worksheet and paste them on a separate
Worksheet. I will always know the primary reference cell.

For example, this week the Worksheet contains 150 rows of information. I
want to copy and paste 50 rows and 5 columns of the information to a
separate worksheet. Assuming a reference cell of $A$1, the 'standard' method
for doing this when the select range is known is: Range("A1:E50").Select.

However, since the number of rows (and columns) changes, I need to
dynamically set the selected range.

It seems that the OFFSET property might work, but I've only been successful
at selecting a single cell rather than a range of cells.

Anyone have any suggestions.

Ron W


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Dynamic Cell Selection

You could create a define range.
Insertnamedefinename it whateverin the refers to
=offset($a$1,0,0,counta($a:$a),counta($1:$1))
This assumes no breaks in the data column or data row.
It there are breaks you would have to do it differently.



--
Don Guillett
SalesAid Software

"Rwem" wrote in message
news:kz7Pc.358$73.144@lakeread04...
I'm looking for a way to dynamically select a range of cells.

I have a spreadsheet in which the number of rows and the number of columns
changes from time to time. By using the Count Worsheet function, I can
determine the number of rows and the number of columns is selected from an
array of values. I want to be able to select and copy a subset of the

total
number of cells contained in the Worksheet and paste them on a separate
Worksheet. I will always know the primary reference cell.

For example, this week the Worksheet contains 150 rows of information. I
want to copy and paste 50 rows and 5 columns of the information to a
separate worksheet. Assuming a reference cell of $A$1, the 'standard'

method
for doing this when the select range is known is: Range("A1:E50").Select.

However, since the number of rows (and columns) changes, I need to
dynamically set the selected range.

It seems that the OFFSET property might work, but I've only been

successful
at selecting a single cell rather than a range of cells.

Anyone have any suggestions.

Ron W




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Dynamic Cell Selection

NumRows = 50
NumColumns = 5
Range("A1").Resize(NumRows,NumColumns).Copy

--
Regards,
Tom Ogilvy

"Rwem" wrote in message
news:kz7Pc.358$73.144@lakeread04...
I'm looking for a way to dynamically select a range of cells.

I have a spreadsheet in which the number of rows and the number of columns
changes from time to time. By using the Count Worsheet function, I can
determine the number of rows and the number of columns is selected from an
array of values. I want to be able to select and copy a subset of the

total
number of cells contained in the Worksheet and paste them on a separate
Worksheet. I will always know the primary reference cell.

For example, this week the Worksheet contains 150 rows of information. I
want to copy and paste 50 rows and 5 columns of the information to a
separate worksheet. Assuming a reference cell of $A$1, the 'standard'

method
for doing this when the select range is known is: Range("A1:E50").Select.

However, since the number of rows (and columns) changes, I need to
dynamically set the selected range.

It seems that the OFFSET property might work, but I've only been

successful
at selecting a single cell rather than a range of cells.

Anyone have any suggestions.

Ron W




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Dynamic Cell Selection

Hi Ron.

Possibly you are looking for the Resize property. For example, from the
intermediate window:

?Range("A1").Offset(2,2).Resize(10, 5).Address

$C$3:$G$12


---
Regards,
Norman


"Rwem" wrote in message
news:kz7Pc.358$73.144@lakeread04...
I'm looking for a way to dynamically select a range of cells.

I have a spreadsheet in which the number of rows and the number of columns
changes from time to time. By using the Count Worsheet function, I can
determine the number of rows and the number of columns is selected from an
array of values. I want to be able to select and copy a subset of the

total
number of cells contained in the Worksheet and paste them on a separate
Worksheet. I will always know the primary reference cell.

For example, this week the Worksheet contains 150 rows of information. I
want to copy and paste 50 rows and 5 columns of the information to a
separate worksheet. Assuming a reference cell of $A$1, the 'standard'

method
for doing this when the select range is known is: Range("A1:E50").Select.

However, since the number of rows (and columns) changes, I need to
dynamically set the selected range.

It seems that the OFFSET property might work, but I've only been

successful
at selecting a single cell rather than a range of cells.

Anyone have any suggestions.

Ron W




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
Dynamic Range Selection Using VBA TEK Excel Discussion (Misc queries) 2 January 23rd 10 04:55 AM
SUBTOTAL - dynamic selection Totteridge Ram Excel Worksheet Functions 3 December 17th 08 01:09 AM
dynamic selection of cells parthaemail New Users to Excel 1 April 25th 06 12:13 PM
Macro - Dynamic cell selection Chris Excel Discussion (Misc queries) 1 January 11th 06 01:48 PM
Dynamic Row Selection Bruce B[_2_] Excel Programming 4 July 14th 03 09:14 PM


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