Simple Error Dialogue box

  • Thread starter Thread starter Rob Gould
  • Start date Start date
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
 
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
 

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

Back
Top