Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
date formatting error
I have users entering info into a worksheet then they click a button to start
the below code. The problem I am having is if they leave it blank I am getting the format error message instead of the date format error message. I have the cell formatted as short date I put the cell into a date variable (mydate) then use mydate in the below code. Even when I put in the date in correct format I seem to be getting the format error message. Any help would be appreciated. If mydate = "" Then x = MsgBox("blank error message", vbCritical, "Error") Range("PeriodFrom").Select Range("PeriodFrom").Activate End Exit Sub Handler: Select Case Err.Number Case 13 'data type mismatch x = MsgBox("Date format error message", vbCritical, "Error") Range("PeriodFrom").Select Range("PeriodFrom").Activate End |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
date formatting error
Arnold,
You are missing a End if and End Select in your code Try this. It worked for me. However if it is blank you get your error message then error 1004. I put in a error handle for error 1004 On Error GoTo Handler If mydate = "" Then x = MsgBox("blank error message", vbCritical, "Error") Range("PeriodFrom").Select Range("PeriodFrom").Activate End End If Exit Sub Handler: Select Case Err.Number Case 1004 Err.Clear Case 13 'data type mismatch x = MsgBox("Date format error message", vbCritical, "Error") Range("PeriodFrom").Select Range("PeriodFrom").Activate End Case Else End Select |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Date formatting error | Excel Discussion (Misc queries) | |||
Date Formatting Error | Excel Discussion (Misc queries) | |||
Excel 2003: Error with date formatting | Excel Discussion (Misc queries) | |||
date formatting error | Setting up and Configuration of Excel | |||
Conditional Formatting - Run Time Error '13' Type Mismatch Error | Excel Programming |