PDA

View Full Version : [SOLVED:] Copy values only not the formats.



PAB
01-24-2017, 12:48 PM
Good evening,

This line of code works...


Range("C8:O8").Copy Range("C" & Rows.Count).End(xlUp).Offset(1, 0)

...but copies the formats etc as well.

How can I get it just to copy and paste the values please?

Thanks in advance.

mancubus
01-24-2017, 02:29 PM
Range.PasteSpecial method:
https://msdn.microsoft.com/en-us/library/office/ff839476.aspx

xlPasteType Enumaration:
https://msdn.microsoft.com/en-us/library/office/ff837425.aspx

PAB
01-25-2017, 03:30 AM
Thanks for the reply mancubus,

I have got it working using...


Range("C8:O8").Copy
With ActiveSheet.Range("C" & Rows.Count).End(xlUp).Offset(1, 0)
.PasteSpecial Paste:=xlPasteValues
End With

I just thought there might have been a one line solution.

Thanks again.

GTO
01-25-2017, 03:53 AM
If just wanting values, another way is:


ActiveSheet.Range("C" & Rows.Count).End(xlUp).Offset(1, 0).Resize(, Range("C8:O8").Columns.Count).Value = Range("C8:O8").Value


Hope that helps,

Mark

PAB
01-25-2017, 04:05 AM
Brilliant, thanks Mark,

I just took out the ActiveSheet. and it works great.