VBA .copy destination

J

jerredjohnson

I have this code:

Worksheets("Sheet1").Range("A1:D4").Copy _
destination:=Worksheets("Sheet2").Range("E5")

doing it this way copies the formatting as well, is there a way to cop
just the value over without the cell format?

Thanks in advanc
 
D

Dave Peterson

One way...

dim RngToCopy as range
Dim DestCell as range

set rngtocopy = worksheets("Sheet1".range("a1:d4")
set destcell = worksheets("sheet2").range("E5")

destcell.resize(rngtocopy.rows.count,rngtocopy.columns.count).value _
= rngtocopy.value

========
Another way is to just copy|paste special|values

dim RngToCopy as range
Dim DestCell as range

set rngtocopy = worksheets("Sheet1".range("a1:d4")
set destcell = worksheets("sheet2").range("E5")

rngtcopy.copy
destcell.pastespecial paste:=xlpastevalues
 
Top