text box validation

Nath_123

Board Regular
Joined
Oct 29, 2008
Messages
116
I'm trying to find some code which when exiting a VBA text box will check its contents are in the right format I.e time or %. What would the code be to throw up a stop message if incorrect?
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Why do you care what the format is in if it's a textbox? Example, whether someone enters
.06
or
6%
it is still the same thing.

What you do with the entry afterwards is really what matters.

Expecting a user to input a text with a format you want will only lead to disappointment; users will do everything except what you want them to.

What you should care about is if they enter the kind of base data you want, example, a number within a range of numbers, or whatever text you have in mind.
 
Upvote 0

Forum statistics

Threads
1,215,711
Messages
6,126,401
Members
449,312
Latest member
sweetfriend9

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