I have a macro that copies data from one sheet and pastes values to another. Everything seems good but I received the error:
Run-time Error 1004: Application-defined or object-defined Error
I simplified the code for your convenience because the whole macro is a set of similar codes:
Sub CopyPaste()
Sheets("Primary").Select
Range("A1").Select
Selection.Copy
Sheets("Result").Range("A2").End(xlToRight).Offset(, 1).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
The debugger shows the problem with the row:
Sheets("Result").Range("A2").End(xlToRight).Offset(, 1).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
I really don't understand what's wrong here. Almost the same code works with another Excel spreadsheet.
I went through similar questions here but couldn't find any that help me. So, maybe it's easy for VBA Professionals but not for me. It's only my second week using VBA, for this reason any help is very appreciated.