Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Copying RANGE of variable length

I am hoping somebody can help me write code that will allow me to copy a
range of variable length.

I have a spreadsheet that will possibly have data from column A to N. While
cells in Column A will ALWAYS have data up to the last row in Column A, the
other cells in other columns could be blank.

I need to copy the data from A1 to the end of column A and across to the
last cell in column N.

Here is my lame attempt at a code and it didn't work. Any help will be
appreciated.

Pele


Worksheets(q).Range(("A1")).End (xlDown),
Range(("A1")).End(xlDown).End(xlRight).Copy


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Copying RANGE of variable length

The trick here is that to define the range you need two points, being the
diagonal corners of the range. The range A1:N100 is the exact same range as
A100:N1... So the range could be defined as

with sheets("Sheet1")
.range(.range("A1").end(xlRight), .range("A1").end(xldown))
end with
--
HTH...

Jim Thomlinson


"Pele" wrote:

I am hoping somebody can help me write code that will allow me to copy a
range of variable length.

I have a spreadsheet that will possibly have data from column A to N. While
cells in Column A will ALWAYS have data up to the last row in Column A, the
other cells in other columns could be blank.

I need to copy the data from A1 to the end of column A and across to the
last cell in column N.

Here is my lame attempt at a code and it didn't work. Any help will be
appreciated.

Pele


Worksheets(q).Range(("A1")).End (xlDown),
Range(("A1")).End(xlDown).End(xlRight).Copy


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Copying RANGE of variable length

Jim,
Can you rewrite your code using Worksheets (q) instead of Sheets("sheet1")
where q is a variable and also include a copy capability.

I tried to change your code as shown below but it didn't work.

For q = 4 To (Worksheets.Count - 1) Step 1
Worksheets(q).Select

With Worksheets(q).Range(.Range("A1").End(xlRight),
..Range("A1").End(xlDown)).copy
End With



"Jim Thomlinson" wrote:

The trick here is that to define the range you need two points, being the
diagonal corners of the range. The range A1:N100 is the exact same range as
A100:N1... So the range could be defined as

with sheets("Sheet1")
.range(.range("A1").end(xlRight), .range("A1").end(xldown))
end with
--
HTH...

Jim Thomlinson


"Pele" wrote:

I am hoping somebody can help me write code that will allow me to copy a
range of variable length.

I have a spreadsheet that will possibly have data from column A to N. While
cells in Column A will ALWAYS have data up to the last row in Column A, the
other cells in other columns could be blank.

I need to copy the data from A1 to the end of column A and across to the
last cell in column N.

Here is my lame attempt at a code and it didn't work. Any help will be
appreciated.

Pele


Worksheets(q).Range(("A1")).End (xlDown),
Range(("A1")).End(xlDown).End(xlRight).Copy


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
Variable series length/range JessK Charts and Charting in Excel 1 March 3rd 06 04:02 AM
Using a Macro to Sum a Variable-Length Range (a Column) Chuckles123[_15_] Excel Programming 0 October 5th 04 06:46 AM
Using a Macro to Sum a Variable-Length Range (a Column) Chuckles123[_9_] Excel Programming 2 October 5th 04 12:34 AM
Using a Macro to Sum a Variable-Length Range (a Column) Chuckles123[_2_] Excel Programming 1 October 3rd 04 11:51 PM
Using a Macro to Sum a Variable-Length Range (a Column) Chuckles123 Excel Programming 2 October 3rd 04 01:12 PM


All times are GMT +1. The time now is 02:21 AM.

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"