I encountered a problem where 1) I cannot paste the copied contents into the desired cell, and 2) an error 1004 PasteSpecial method of Range class failed popped up.
Here's my code:
For problem 1), the copied contents were copied into cell H1 instead of cell G2 (which is the desired cell). It also didn't work when I changed 'selection' to 'Range("G2")'. Please help.
Here's my code:
VBA Code:
'copy whole content from old quarter file with header added
Windows("Report002_" & year & "Q" & quarter & ".xls").Activate
Rows(1).Insert
Range("a1").Value = year & "Q" & (quarter + 1)
Range("a1:f1442").Select
Selection.Copy
'paste content to new quarter file and close the old quarter file
Windows("Report002_" & year & "Q" & (quarter + 1) & ".xls").Activate
Rows(1).Insert
Columns(1).Insert
Range("G1").Value = year & "Q" & quarter
Range("G2").Select
Selection.PasteSpecial Paste:=xlPasteValues
ActiveWorkbook.Save
Windows("Report002_" & year & "Q" & quarter & ".xls").Close