VBA to "Exit Sub" when "Data Validation" error is triggered

EssKayKay 0 Reputation points
2023-11-04T14:56:35.8366667+00:00

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.

======================================================

EDIT - 

My current issue is in regards to Data Validation criteria.  I have a cell with an associated dropdown list.  All works fine if the user only selects an option (date) from the list.  However, I want the user to also be able to “keyin” a date.  Again this is fine if the user keys in an acceptable date.  However, if the user keys in an unacceptable date (i.e., one that is not in the list) the Data Validation’s “stop” error message pops up with the Retry/Cancel /Help buttons, which is great.  However, what I want is if the user selects “Cancel” I want the routine to truly stop (i.e., something like an If/Then with an Exit Sub). 

My question – is there a way to stop/exit a Sub-Routine if/when the user clicks on the Data Validation’s Stop error’s “Cancel” button? 

Thanks,
Steve

Microsoft 365 and Office Development Other
Microsoft 365 and Office Excel For business Windows
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.