I am trying to paste a range into a sheet which has it's name defined by a cell in excel. This is the code
Sub copynotes()
Dim xcopy, xpaste As Range
Dim Analystname As String
Analystname = Sheets("Admin").Range("g2")
'Sheets(Analystname).Select
xcopy = Range("j2:n2")
xpaste = Sheets(Analystname).Range("a2")
xcopy.Copy Destination:=xpaste
End Sub
I receive an error at "xpaste Sheets(Analystname).Range("a2")"
(Object variable or with block variable not set)
However the sheet seems to be properly defined since vba can select it.
Could you please help me understand what is the issue with the code?
Thank you for your time