View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Copy and paste between sheets

If you need to qualify Range, then you need to qualify Cells as well.

With Sheets(1)
.Range(.Cells(1, 1), .Cells(1, 4)).Copy Sheets(2).Cells(1, 1)
End With

--
Regrards,
Tom Ogilvy


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
this should do what your example is trying to do

Sheets(1).Range(Cells(1, 1), Cells(1, 4)).Copy Sheets(2).Cells(1, 1)

--


Gary


"dmg" wrote in message
nk.net...
I need to copy data in one sheet to another. The data to be copied is of
different sizes, may be in different locations on the source sheet and

has
varying strings that define the top-left and bottom-right cells depending
on the situation. And the sheet names will also vary.

To simplify the problem, I have removed the variables and have inserted
number in the cell ranges. I need to understand why this works:

Sheets(2).Range("A1").Value = Sheets(1).Range("A1:D1").Value

and this produces a '1004' Application defined or Object defined error

Sheets(2).Range(cells(1,1)).Value = Sheets(1).Range(cells(1,1),
cells(1,4)).Value

I have also tried:

Sheets(1).Select
Sheets(1).Range(Cells(1, 1), Cells(1, 4)).Select
Selection.Copy
Sheets(2).Select
Range(Cells(1, 1)).Select
ActiveSheet.Pastevalue

But this produces a 1004 error at the line "Range(Cells(1, 1)).Select"