cdate problem

  • Thread starter Thread starter JohnP
  • Start date Start date
J

JohnP

Hi,

I have some code for user forms that require date entry. Some of the date
fields can be left blank but when the code runs it errors out because my code
refers to a blank variable as a cdate. I have phrased this statement within
an if so that it should only run if the date field is not blank but it still
comes up as a type mismatch error.

Any ideas? Let me know if you need more explanation.

Thanks in advance for any help you can offer.

JohnP
 
Hi Rick,

See code section below. I know its not the best. Still quite new to this!

Thanks,

If FromFullDate.Value <> "" Then
Sheets("Template").Select
Range("A9").Activate
j = 9
While CDate(ActiveCell.Value) <> CDate(FromFullDate.Value)
ActiveCell.Offset(1, 0).Activate
j = j + 1
Wend
If ActiveCell.Interior.ColorIndex = 1 Then
Application.ScreenUpdating = True
MsgBox Prompt:="" & CDate(FromFullDate.Value) & " is a weekend or a bank
holiday. Please select a weekday.", _
Buttons:=vbOKOnly + vbExclamation
FromFullDate = ""
Exit Sub
End If
End If
 
While the code is not how I would have written it, it appears to work fine
from the test I did. Tell us *exactly* what problem are you having that
prompted you to ask your question (give details so we can reproduce the
problem on our own computers)?

Rick
 

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