+ Reply to Thread
Results 1 to 5 of 5

Macro Error Message

  1. #1
    Registered User
    Join Date
    11-24-2015
    Location
    london
    MS-Off Ver
    10
    Posts
    33

    Macro Error Message

    I want to share my macros with my colleagues. However, if they were to run the macro incorrectly which is bound to happen at the start, on the wrong sheet, an error messages comes up, as shown in attachment.

    They can click on the Debug option and this will bring up the macro code. However, I don’t want them to do this because they might delete the code. What are the best options to prevent this?

    I read up on password protection here or should I use an Excel VBA On Error Statement?

    Ideally, I would like it to display an error message that just say’s ‘You have used this on the incorrect sheet, please try again.’

    Example of one of my macro codes, do I put the macro error code in the same module?

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Macro Error Message

    should I use an Excel VBA On Error Statement?
    Example of one of my macro codes, do I put the macro error code in the same module?
    Yes to both questions.

  3. #3
    Registered User
    Join Date
    11-24-2015
    Location
    london
    MS-Off Ver
    10
    Posts
    33

    Re: Macro Error Message

    Quote Originally Posted by Logit View Post
    Yes to both questions.
    I put this together but when I run the macro it displays the error message even though the macro has performed the code correctly.

    I wanted it to display the error message only if the code was run incorrectly, can you see what I have done wrong?

    HTML Code: 

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Macro Error Message

    You need an Exit Sub line before the ErrorMessage: line
    Rory

  5. #5
    Registered User
    Join Date
    11-24-2015
    Location
    london
    MS-Off Ver
    10
    Posts
    33

    Re: Macro Error Message

    Quote Originally Posted by rorya View Post
    You need an Exit Sub line before the ErrorMessage: line
    It works! something so simple. Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 5
    Last Post: 12-08-2016, 06:43 PM
  2. Error message macro
    By Engineeronamission in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-10-2014, 04:00 AM
  3. [SOLVED] Error message when trying to record a macro - No Personal Macro Workbook
    By KimC in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-14-2014, 06:56 PM
  4. [SOLVED] Error in my Message box Macro
    By Sjoerdvdbosch in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-17-2012, 08:32 AM
  5. Error message on macro
    By zmbd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-11-2011, 04:24 AM
  6. Need Error Message for macro
    By Launchnet in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-12-2009, 12:24 AM
  7. Macro Error Message
    By MrMe in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-24-2006, 06:39 AM

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