Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 195
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date formatting error Cindyt Excel Discussion (Misc queries) 1 August 5th 09 03:21 PM
Date Formatting Error Cookie Excel Discussion (Misc queries) 2 October 9th 08 09:24 AM
Excel 2003: Error with date formatting bird007 Excel Discussion (Misc queries) 0 June 9th 08 06:44 AM
date formatting error TMF in MN Setting up and Configuration of Excel 1 September 29th 06 05:02 PM
Conditional Formatting - Run Time Error '13' Type Mismatch Error ksp Excel Programming 0 July 11th 06 07:06 AM


All times are GMT +1. The time now is 05:32 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"