Copy range without changing sheet in view?

W

William DeLeo

Greetings,

I need to use a macro to copy cell values from one sheet to anothe
without changing the sheet that's in view. I have been using th
following code but my selection method causes the sheet in view to fli
back and forth between the sheet the cells are being copied from to th
one they are being pasted on.

I am using the follwing:

Sheets("Sheet1Name").Select
Range("D4").Select
Selection.Copy

Sheets("Sheet2Name").Select
Range("C5").Select
ActiveSheet.Paste

How can I rewrite this to do all the work in the background? I guess
need the syntax to copy a range from a sheet without making i
"Active".

Thanks in advance!
 
B

Bob Phillips

Sheets("Sheet1Name").Range("D4").Copy Destination:= _
Sheets("Sheet2Name").Range("C5")

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
R

Ron de Bruin

Try this William

Sub test()
Sheets("Sheet1Name").Range("D4").Copy _
Sheets("Sheet2Name").Range("C5")
End Sub
 
W

William DeLeo

As easy as that is, I was having trouble figuring out the syntax.

I appreciate your help very much. Thank you
 
W

William DeLeo

I see that you are not using the Paste command at all ... how would you
advice apply if I were using paste special
 
R

Ron de Bruin

Use something like this


Sub test()
Sheets("Sheet1Name").Range("D4").Copy
Sheets("Sheet2Name").Range("C5").PasteSpecial xlPasteValues, , False, False
Application.CutCopyMode = False
End Sub
 
Top