Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default copy variable length cells to a new sheets

I would like to copy a range of cells in to a new spreadsheet.

I have following code, but it does not work for variable length cells

Dim wsSource wsDestination As Worksheet
Dim rFrom, rTo As Range

Set wsSource = Sheets("SHEET1")
Set wsDestination = Sheets("SHEET2")
Set rOld = wsSource.Range("A1:C15")
Set rNew = wsTarget.Range("A1")

rOld.Copy Destination:=rNew

Number of ciolumns is known, but I would like to change the number of rows.
Are there any easy way to programming change row number of rOld?

Any information is great appreciated,

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default copy variable length cells to a new sheets

Hi Souris,

Set rOld = wsSource.Range("A1:C15")


Perhaps,

Set rOld = Range("A1").CurrentRegion


---
Regards,
Norman



"Souris" wrote in message
...
I would like to copy a range of cells in to a new spreadsheet.

I have following code, but it does not work for variable length cells

Dim wsSource wsDestination As Worksheet
Dim rFrom, rTo As Range

Set wsSource = Sheets("SHEET1")
Set wsDestination = Sheets("SHEET2")
Set rOld = wsSource.Range("A1:C15")
Set rNew = wsTarget.Range("A1")

rOld.Copy Destination:=rNew

Number of ciolumns is known, but I would like to change the number of
rows.
Are there any easy way to programming change row number of rOld?

Any information is great appreciated,



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default copy variable length cells to a new sheets

Thanks for the information,

CurrentRegion copies all the region, but I want to copy part of them.

For example: I wanted to copy "A1:C15", My data are in "A1:F15".
CurrentRegion copy from A1:F15, which I do not need "D1:F15"

May I specify the number of columns or I can delete the row I do not need
after copy?

Thanks again,

"Norman Jones" wrote:

Hi Souris,

Set rOld = wsSource.Range("A1:C15")


Perhaps,

Set rOld = Range("A1").CurrentRegion


---
Regards,
Norman



"Souris" wrote in message
...
I would like to copy a range of cells in to a new spreadsheet.

I have following code, but it does not work for variable length cells

Dim wsSource wsDestination As Worksheet
Dim rFrom, rTo As Range

Set wsSource = Sheets("SHEET1")
Set wsDestination = Sheets("SHEET2")
Set rOld = wsSource.Range("A1:C15")
Set rNew = wsTarget.Range("A1")

rOld.Copy Destination:=rNew

Number of ciolumns is known, but I would like to change the number of
rows.
Are there any easy way to programming change row number of rOld?

Any information is great appreciated,




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default copy variable length cells to a new sheets

Hi Souris,

Try:

Range("A1").CurrentRegion.columns("A:C").select


---
Regards,
Norman



"Souris" wrote in message
...
Thanks for the information,

CurrentRegion copies all the region, but I want to copy part of them.

For example: I wanted to copy "A1:C15", My data are in "A1:F15".
CurrentRegion copy from A1:F15, which I do not need "D1:F15"

May I specify the number of columns or I can delete the row I do not need
after copy?

Thanks again,

"Norman Jones" wrote:

Hi Souris,

Set rOld = wsSource.Range("A1:C15")


Perhaps,

Set rOld = Range("A1").CurrentRegion


---
Regards,
Norman



"Souris" wrote in message
...
I would like to copy a range of cells in to a new spreadsheet.

I have following code, but it does not work for variable length cells

Dim wsSource wsDestination As Worksheet
Dim rFrom, rTo As Range

Set wsSource = Sheets("SHEET1")
Set wsDestination = Sheets("SHEET2")
Set rOld = wsSource.Range("A1:C15")
Set rNew = wsTarget.Range("A1")

rOld.Copy Destination:=rNew

Number of ciolumns is known, but I would like to change the number of
rows.
Are there any easy way to programming change row number of rOld?

Any information is great appreciated,






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default copy variable length cells to a new sheets

run-time error 424 object required.



"Norman Jones" wrote:

Hi Souris,

Try:

Range("A1").CurrentRegion.columns("A:C").select


---
Regards,
Norman



"Souris" wrote in message
...
Thanks for the information,

CurrentRegion copies all the region, but I want to copy part of them.

For example: I wanted to copy "A1:C15", My data are in "A1:F15".
CurrentRegion copy from A1:F15, which I do not need "D1:F15"

May I specify the number of columns or I can delete the row I do not need
after copy?

Thanks again,

"Norman Jones" wrote:

Hi Souris,

Set rOld = wsSource.Range("A1:C15")

Perhaps,

Set rOld = Range("A1").CurrentRegion


---
Regards,
Norman



"Souris" wrote in message
...
I would like to copy a range of cells in to a new spreadsheet.

I have following code, but it does not work for variable length cells

Dim wsSource wsDestination As Worksheet
Dim rFrom, rTo As Range

Set wsSource = Sheets("SHEET1")
Set wsDestination = Sheets("SHEET2")
Set rOld = wsSource.Range("A1:C15")
Set rNew = wsTarget.Range("A1")

rOld.Copy Destination:=rNew

Number of ciolumns is known, but I would like to change the number of
rows.
Are there any easy way to programming change row number of rOld?

Any information is great appreciated,









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default copy variable length cells to a new sheets

Dim wsSource As Worksheet
Dim wsTarget As Worksheet
Dim rOld As Range
Dim rNew As Range
Dim eRow As Long

Set wsSource = Sheets("SHEET1")
Set wsTarget = Sheets("SHEET2")
eRow = wsSource.Cells(Rows.Count, 1).End(xlUp).Row
Set rOld = wsSource.Range("A1:C" & eRow)
Set rNew = wsTarget.Range("A1")

rOld.Copy Destination:=rNew

PS if you dim your variables:

Dim wsOne, wsTwo as Worksheet

wsOne will be a variant and only wsTwo will be correctly dimmed.

Hope this helps
Rowan

"Souris" wrote:

I would like to copy a range of cells in to a new spreadsheet.

I have following code, but it does not work for variable length cells

Dim wsSource wsDestination As Worksheet
Dim rFrom, rTo As Range

Set wsSource = Sheets("SHEET1")
Set wsDestination = Sheets("SHEET2")
Set rOld = wsSource.Range("A1:C15")
Set rNew = wsTarget.Range("A1")

rOld.Copy Destination:=rNew

Number of ciolumns is known, but I would like to change the number of rows.
Are there any easy way to programming change row number of rOld?

Any information is great appreciated,

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
Copy cells to variable number of rows Acct Supr - DCTC Excel Discussion (Misc queries) 5 September 26th 09 12:58 PM
Copy Cells - using Variable dhstein Excel Discussion (Misc queries) 3 July 19th 09 04:19 AM
Copy only Visible Cells of a Variable Range... Damian Carrillo[_2_] Excel Programming 2 July 21st 05 01:12 AM
copy sheets of cell length is more than 255 char ilyaskazi[_46_] Excel Programming 2 July 11th 05 09:34 AM
Parsing data - variable length cells Karen[_11_] Excel Programming 2 January 8th 04 11:19 PM


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