On Error command

Sade

Board Regular
Joined
Nov 29, 2004
Messages
145
I am using an On Error command to ensure the user inputs a properly formatted date in the userform. It prompts the user that the entry is improper, then loops back to the top of the macro and asks for input again.

The first time through, it works fine. However, after being sent back to the top of the macro, the On Error command doesn't work. It reaches the same test spot, and if it is still an invalid entry, the macro fails with a "Type Mismatch" error, instead of going to the designated On Error portion again.

I hope this makes sense, and thanx for any insight you can give on this issue.

Travis
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
There are usually better ways than using an On Error type command for ensuring a correct date is entered in a userform. Might I suggest three seperate fields? One for the month, day and year; each using a combobox (drop down) where YOU can control what they choose. Then you can construct a date from the entries and you know exactly what they are entering and it IS a good date.

And btw, it's probably failing in lieu of your variable declaration.
 
Upvote 0
Hmm, good point. I'll try breaking up the date. It will probably be cleaner and safer that way.

thanx.
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,824
Members
449,050
Latest member
Bradel

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