The below code produces the error "Run-time error '1004': Method 'Range' of object"_Worksheet' failed" if the referenced sheet is not active. However, If I have the sheet active and run the code everything works. I believe the worksheet in question is properly set as an object for the code to reference and I have tried several different setups to target it.
Private Sub clearImport()
Dim Ws As Worksheet
Set Ws = ThisWorkbook.Sheets("Returned")
k = Ws.Range("P65536").End(xlUp).Offset(1).Row
Ws.Range(Cells(2, 1), Cells(k, 23)).Delete
End Sub