Reputation: 207
I am looking to paste values for the following piece of code. I tried using paste special a variety of ways but it does not let me specify both the file and what type of pasting I want to do.
To be clear, the code I am using works, but I would like to modify it so it pastes only values.
Workbooks.Open (path & file)
ActiveSheet.Paste (Workbooks(file).Sheets(5).Range("A1").End(xlDown).Offset(1, 0))
Workbooks(file).Close SaveChanges:=True
Thank you!
Upvotes: 0
Views: 238
Reputation: 2670
Instead of using the PasteSpecial
associated with a worksheet object, use the one associated with the destination object:
Workbooks(file).Sheets(5).Range("A1").End(xlDown).Offset(1, 0).PasteSpecial xlPasteValues
OR
You can work directly with the values and avoid using the clipboard (which you could be trying to use for other things while your macro is running):
Dim src as Range
Dim dest as Range
'Set src to where you had copied from
Set dest = Workbooks(file).Sheets(5).Range("A1").End(xlDown).Offset(1, 0)
dest.value = src.value
Upvotes: 2