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
 

Some videos you may like

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Zack Barresse

MrExcel MVP
Joined
Dec 9, 2003
Messages
10,881
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
  3. Web
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.
 

Sade

Board Regular
Joined
Nov 29, 2004
Messages
145
Hmm, good point. I'll try breaking up the date. It will probably be cleaner and safer that way.

thanx.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,213
Messages
5,594,870
Members
413,945
Latest member
V51773

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
Top