Compile error - Excel VBA

Anonymous
2020-04-14T14:34:25+00:00

Hello all,

Microsoft Excel version: Microsoft Professional + 2016

VBA Sub code: Clear_Existing_Data_Before_Paste ( )

I used below code a few times without any problems. This time I got a "Compile error: Invalid use of property" notification.

I`ve not made any changes to the coding, does somebody know how to write the code that it becomes more stable and less error-prone?

Below are two screenshots, first screenshot is of the notification and the second screenshot marked the error. 

Screenshot 1:

Screenshot 2:

Any idea is welcome, thanks for your effort.

Kind Regards,

Erik

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} vote

7 answers

Sort by: Most helpful
  1. Andreas Killer 144K Reputation points Volunteer Moderator
    2020-04-14T17:51:33+00:00

    Hello Andreas, thanks for your reply. I made the change as you advised, unfortunately the code does not copy the data in the worksheet anymore. 

    Erik,

    Please paste the code as text here, thanks.

    Andreas.

    0 comments No comments
  2. Anonymous
    2020-04-14T18:21:04+00:00

    In response to "Any idea ..."

    I suggest you use Option Explicit at the top of the module.

    I have only glanced at your code, but I don't see Dim or definition for wsN.

    0 comments No comments