+ Reply to Thread
Results 1 to 6 of 6

Compile Error: Invalid Use of Property on stupidly simple code

  1. #1
    Registered User
    Join Date
    04-11-2013
    Location
    Derby, England
    MS-Off Ver
    Excel 2007
    Posts
    4

    Compile Error: Invalid Use of Property on stupidly simple code

    Evening all,

    I have a userform with a button on it. That button, when clicked, should call a separate macro. So far I haven't made the separate macro all that difficult as I am just testing things out. Also I'm pretty sure I've done this before and it worked just fine but at this point I'm getting compile error: invalid use of property.

    The Userform code reads:
    Please Login or Register  to view this content.
    and in a separate module the temporary code reads:
    Please Login or Register  to view this content.
    Any idea what I can be missing? That really is the only code in my worksheet at the moment and running through the ClearVehicles Sub manually will pop up a happy little MsgBox as I told it to.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Compile Error: Invalid Use of Property on stupidly simple code

    Can't replicate the error.

    Is that definitely the only code in the workbook?

    Do you get a debug option when you get the error message?

    If you don't goto Tools>Options... and on the General tab select Break on all Errors or Break in Class Module, then try the code again.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    04-11-2013
    Location
    Derby, England
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Compile Error: Invalid Use of Property on stupidly simple code

    The only other code on the worksheet is an on open event which opens the userform. Everything else is blank. The Workbook_Open event is also simple and works just fine.

    I restarted the laptop as occasionally Excel decides that perfectly good code won't run until you do but still no joy.

    Breaking on class module etc doesn't seem to give any sensible debug options but will show the error here:

    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Compile Error: Invalid Use of Property on stupidly simple code

    Hi,

    change the name of the Sub with the MsgBox to something else.

    Mark this thread SOLVED and click the star if this answer solves your problem.

    Regards
    Please use [CODE]-TAGS
    When your problem is solved mark the thread SOLVED
    If an answer has helped you please click to give reputation
    Read the FORUM RULES

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Compile Error: Invalid Use of Property on stupidly simple code

    Actually I misread the original post and thought it was a runtime error not a compile error.

    Have a look under Tools>References... and see if anything listed is marked as MISSING.

    If there is anything uncheck it, but note it's name first, then save, close and exit Excel.

    Then re-open the workbook and give the code a try.

  6. #6
    Registered User
    Join Date
    04-11-2013
    Location
    Derby, England
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Compile Error: Invalid Use of Property on stupidly simple code

    Quote Originally Posted by tehneXus View Post
    Hi,

    change the name of the Sub with the MsgBox to something else.

    Mark this thread SOLVED and click the star if this answer solves your problem.

    Regards
    It appears that Excel gets confused if things are named the same. Didn't realise >_<

    This has solved the issue, thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1