Date and error checking

  • Thread starter Arnold Klapheck
  • Start date
A

Arnold Klapheck

I am trying to give an error message if a user leaves a date field blank,
however my code is not catching it as blank it throws a 13 error message
(which i catch and give a message NOT in correct format
Mytime = Sheets("Program Controls").Range("F8").Value
' F8 is blank
'this is throwing an error 13 when I look at Mytime it shows
12:00:00 AM
If Mytime = "" Or MyTime = Null Or Mytime = #12:00:00 AM# Then
msgbox ("error message, cannot leave date blank")

Handler:
Select Case Err.Number
Case 13
x = MsgBox("Make sure your dates are in the right format MM/DD/YY"

any help would be appreciated,
 
A

Arnold Klapheck

I figured it out insteat of assigning to variable use the cell reference
then assign to variable just befor error handler.

If Sheets("Program Controls").Range("F8").Value = "" Then
x = MsgBox("You must enter Period From Date", vbCritical, "Error")
Range("PeriodFrom").Select
Range("PeriodFrom").Activate
End
end if
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Adding date and time to cell programatically? 3
Time Format in a ComboBox 4
Workbook reminder 0
separating date and time 5
MACROS DATES 4
type mismatch error in macro in excel 0
Edit Date 1
error handling date 1

Top