问题
I have the following code in order to copy a sheet from a workbook and paste it on the sheet 1 of another workbook called "Control_de_precios":
Sub createSpreadSheet()
Set NewBook = Workbooks.Add
With NewBook
.Title = "Control_precios_ddmmaaaa"
.Subject = "Control_de_precios"
.SaveAs Filename:="Control_precios_ddmmaaaa.xls"
End With
ThisWorkbook.Worksheets(1).Activate
Cells.Select
Selection.Copy
NewBook.Sheets(1).Activate
ActiveSheet(1).PasteSpecial xlPasteValues
End Sub
The problem is that I get the 438 error because the last instruction, and I don't get to paste values on my new workbook. If I change it for:
ActiveSheet(1).Paste
I don't get the 438 error, and I get to paste the formulas, but I want to paste the values.
¿Could anyone help me?
回答1:
Add Range reference after the activesheet. When I do it this way it works. ActiveSheet.Range("A1").PasteSpecial xlPasteValues
回答2:
Write
Selection.PasteSpecial xlPasteValues
instaed of
ActiveSheet(1).PasteSpecial xlPasteValues
来源:https://stackoverflow.com/questions/45937731/problems-pasting-values-on-another-workbook-sheet-on-vba