Simple Error Dialogue box

R

Rob Gould

Hi,

I have the text "Enter date here" in cell C1. A user needs to override
this with a date before clickling a button on the sheet to run a macro.
How can I add code to this button to ensure that a date is entered?
That is, if they forget to enter a date, I would like a box to pop up
reminding them to enter one.

Thanks

Rob
 
J

Jason Morin

Try something like:

Private Sub CommandButton1_Click()
If Not IsDate([C1].Value) Then
MsgBox "Please enter a date in C1!"
[C1].Value = "Enter date here"
Exit Sub
Else
'Rest of code here
End If
End Sub
 
Top