PDA

View Full Version : Paste Values



Alex O
06-09-2011, 06:42 AM
I thought this would paste values only, but for some reason it's pasting my formulas. How can this macro be edited to copy and paste values?

Thanks

Sub NewUploadFile()
Dim wb As Workbook
Set wb = Workbooks.Add
'copy and paste
ThisWorkbook.Worksheets(1).Range("B1:P2000").Copy _
Destination:=wb.Sheets("Sheet1").Range("A1")
wb.Sheets("Sheet1").Columns.AutoFit
Set wb = Nothing
End Sub

Simon Lloyd
06-09-2011, 12:10 PM
This should be what you need:Sub NewUploadFile()
Dim wb As Workbook
Set wb = Workbooks.Add
'copy and paste
ThisWorkbook.Worksheets(1).Range("B1:P2000").Copy
wb.Sheets("Sheet1").Range("A1").PasteSpecial Paste:=xlPasteValues
wb.Sheets("Sheet1").Columns.AutoFit
Set wb = Nothing
End Sub

Alex O
06-09-2011, 02:47 PM
Perfect....thanks!