Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default validate data using code

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(IS BLANK(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?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default validate data using code

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)))"


Gareth wrote:
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(IS BLANK(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?




--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code/Function to Look at Previous Entry to Validate Data Steve Excel Worksheet Functions 6 February 9th 09 07:06 AM
validate data using formulae jatman Excel Worksheet Functions 4 February 5th 09 01:48 AM
Validate Data Message Box Judi Excel Discussion (Misc queries) 2 July 11th 08 11:09 PM
Validate cells have data WendyUK Excel Worksheet Functions 9 August 13th 05 01:33 AM
How to validate in code the contents of a cell? Heather M. Excel Programming 1 November 11th 03 08:14 AM


All times are GMT +1. The time now is 06:23 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"