View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default Range(sheet2) = Range(sheet1)

Instead of this which does the job but leaves the range on sheet 2
selected:

Sheets("Sheet1").Range("A2:F2").Copy
Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp)(2).PasteSpecial
Paste:=xlPasteValues

I'm trying to do the code line whe

(Sheet2)Range = (sheet1)Range and does the offset & paste special
also

Thanks.

Howard


No need for copy/paste when assigning values only. Both ranges need to
be the same size when assigning values...

rngTarget.Value = rngSource.Value

...where rngTarget is sized same as rngSource before assigning the
values...

With rngSource
rngTarget.Resize(.Rows.Count, .Columns.Count) = rngSource.Value
End With

...where rngTarget is 'Set' to the 1st cell position and the resize does
the rest!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion