validate data using code

G

Gareth

I have the following code which works fine on range dob:

With Range("dob").Validation
.Add Type:=xlValidateCustom, AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, _

Formula1:="=AND(I2>=29221,I2<=TODAY(),I2<=J2,OR(ISBLANK(K2),I2<=K2),OR(ISBLA
NK(L2),I2<=L2))"
.IgnoreBlank = False
.ErrorTitle = "Date of birth"
.ErrorMessage = "Entry must be a date between 01/01/1980 and today."
& Chr(10) & Chr(10) & "It cannot be greater than either the on, off or died
date."
End With

Range dob does however contain blank cells and these show up as validation
errors. Is there any way to amend the code so as not to use .IgnoreBlank =
False, which I think is causing them to show as errors?
 
D

Debra Dalgleish

You can change the formula:


Formula1:="=OR(ISBLANK(I2),AND(I2>=29221,I2<=TODAY(),I2<=J2,OR(ISBLANK(K2),I2<=K2),OR(ISBLANK(L2),I2<=L2)))"
 

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

Top