Stop Code - Override textbox validation

03856me

Active Member
Joined
Apr 4, 2008
Messages
297
I have a userform with many textboxes - some of which have requirements to enter valid data or that cannot be left blank. My users have requested a let's say "Master Clear" button that would override all restrictions on the form and allow them to start over, or basically Re-load the form. I am thinking this would work like a CTRL+BREAK but I am not sure how to do this in vba or if it can be done.

My initial thought was this isn't possible because of the enter and exit events, but I don't know what I don't know, so I thought I would ask.
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
use EnableEvents to control the firing of event handlers

Application.EnableEvents = False
UserForm1.TextBox1.Value = ""
...
Application.EnableEvents = True
 
Upvote 0
Why not change the validation so that it doesn't stop the user leaving the textbox but does something like changing the background colour to red?

As for re-loading the form you would normally use something like this.
Code:
Unload Me
 
UserForm1.Show
That wouldn't work if you were stopping the user exit textboxes though.

Another alternative - don't check the data until the user has been through all the textboxes.

Have them click a button that will check the data and move on to the next step only if everything is OK, otherwise highlight all the errors and ask the user to rectifgy them.
 
Upvote 0

Forum statistics

Threads
1,215,467
Messages
6,124,984
Members
449,201
Latest member
Lunzwe73

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top