+ Reply to Thread
Results 1 to 7 of 7

Stop a Macro if Criteria not met and Show Error Message

  1. #1
    Registered User
    Join Date
    06-17-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    3

    Stop a Macro if Criteria not met and Show Error Message

    Hello!

    I'm fairly new to VBA and have a question, something probably quite simple to fix

    I am trying to work a simple Macro which looks at the item selected on a dropdown (through data validation) for acceptance of Terms and Conditions. If agreed, I want to unhide another tab, if disagree selected, then an error message should be shown and the tab should not be unhidden.

    I have managed to get the error message for disagree, however it still unhides the tab any advice here will be greatly appreciated.

    Please Login or Register  to view this content.
    Many thanks,
    Mez
    Last edited by m3hool; 06-17-2013 at 10:11 AM.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Stop a Macro if Criteria not met and Show Error Message

    Mez,
    Please code tags with your code.

    You have Sub Worksheet_Change, but where is the target?

    You need to call Sub unhide() from Sub Worksheet_Change

  3. #3
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Stop a Macro if Criteria not met and Show Error Message

    Of course, unhiding a tab before you check if they actually agreed is never a good idea...
    Try this :

    Please Login or Register  to view this content.
    Please click the * below if this helps

  4. #4
    Registered User
    Join Date
    06-17-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Stop a Macro if Criteria not met and Show Error Message

    Brilliant thank you so much it worked!

  5. #5
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,111

    Re: Stop a Macro if Criteria not met and Show Error Message

    Again:
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code in [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    Never use Merged Cells in Excel

  6. #6
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,111

    Re: Stop a Macro if Criteria not met and Show Error Message

    JasperD:
    Your post does not comply with Rule 7 of our Forum RULES. Please do not ignore requests by Administrators, Moderators and senior forum members regarding forum rules.

    If you are unclear about the request or instruction then send a private message to them asking for clarification. Do not post a reply in a thread where a moderator has requested an action that has not yet been complied with e.g Title change or Code tags...etc

  7. #7
    Registered User
    Join Date
    06-17-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Stop a Macro if Criteria not met and Show Error Message

    Apologies, now corrected.
    Mez

+ 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