+ Reply to Thread
Results 1 to 3 of 3

Data Validation - Stop/Cancel options?

  1. #1
    Registered User
    Join Date
    10-21-2023
    Location
    Wisconsin
    MS-Off Ver
    2007
    Posts
    22

    Data Validation - Stop/Cancel options?

    I have a cell with assigned Data Validation criteria. If the user inputs an erroneous value it returns the “Stop” Error Alert with the Retry/Cancel/Help buttons.

    Upon entering data in the cell another routine is triggered. Is it possible that if the user selects the “Cancel” option the remaining routine would also be cancelled? That is, something like Exit Sub upon selecting Cancel.

    Thanks for viewing,
    Steve

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Data Validation - Stop/Cancel options?

    What is the other routine? Are you using Worksheet_Change? What functionality does it perform? It would be better to actually show us your code, and best of all to attach your file (see yellow banner at the top of the page).

    Worksheet_Change detects only if the cell content changes. When you type an invalid value into the cell, that is a change. So your routine is triggered, and there is no going back. Then when Data Validation rejects it on Cancel, that's another change. VBA cannot detect that you clicked Cancel. For the behavior you want, you would have to develop the entire data validation in VBA instead of using built-in data validation.

    However, depending on what you want to do when the cell is updated, alternative solutions might be possible. It all depends on what you're trying to do.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    10-21-2023
    Location
    Wisconsin
    MS-Off Ver
    2007
    Posts
    22

    Re: Data Validation - Stop/Cancel options?

    Well Jeff, sorry for being so deficient.

    I was a bit hesitant to post the worksheet. I must first stress, I am not a programmer. I’m sure you and others would be amazed at how sloppy my coding is, but for the most part it works. Attached is a copy my worksheet. This is a work in progress so not all operations are complete.


    Example:
    My current quest is when an unacceptable value is entered into cell K10 without anything entered into K9. As a test, enter 1-1-23 in K10. This will trigger the Validation error. This is where if “Cancel” is selected, I would like the remaining code to Exit Sub or something.

    If you feel I’m asking for a bit too much here, please simply disregard this post.

    Thanks,
    Steve K.
    Attached Files Attached Files
    Last edited by S.K.K.; 11-01-2023 at 02:10 PM.

+ 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. [SOLVED] Message box with three options -yes,no,cancel
    By Chanty in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-25-2021, 12:36 PM
  2. [SOLVED] i need to cancel data validation across a large workbook
    By Trebor777 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-14-2017, 08:13 AM
  3. Options Other Than Data Validation
    By rahul_ferns76 in forum Excel General
    Replies: 4
    Last Post: 04-21-2017, 12:41 AM
  4. [SOLVED] Yes / No / Cancel options in macro
    By robertguy in forum Excel General
    Replies: 2
    Last Post: 07-11-2016, 05:20 PM
  5. Yes No and Cancel Options
    By rucker222 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-17-2013, 04:27 AM
  6. Stop Worksheet_Change macro if validation not met in Data Validation
    By Wizz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-20-2010, 12:26 PM
  7. [SOLVED] Example of box with more than OK and cancel options?
    By StargateFan in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-09-2005, 12:05 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