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

Debra

Many thanks for this, it works fine. One problem I have with it is that the
range "dob" extends further, ie, it contains about 200 rows of empty cells
which the user will complete.

The validation is there but when the user checks for validation errors
(Tools | Auditing | etc) it will show up errors in these cells until he/she
enters data. Is there any way to amend the formula to avoid seeing any
errors in the blank cells in range "dob" (column I)?

Gareth

"Debra Dalgleish" wrote in message
...
You can remove the check mark from Ignore Blanks, and revise your
formula slightly:

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


Gareth wrote:
I have the folowing code which works fine when there is data in all the
cells referenced. Unfortunately, column's K and L do not always have

data
in them (all cells are date cells).

This causes the validation not to work.

With Range("dob").Validation
.Add Type:=xlValidateCustom, AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween,
Formula1:="=AND(I2=29221,I2<=TODAY(),I2<=J2,I2<=K 2,I2<=L2)”
.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

Is there a way around it?

Many thanks.

Gareth




--
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 to find data validation in a cell DaveO[_2_] Excel Discussion (Misc queries) 1 March 19th 07 05:53 PM
Validation of Postal Code Veronika Excel Worksheet Functions 1 December 16th 05 09:42 PM
Data validation using code Gareth[_3_] Excel Programming 1 November 26th 03 12:27 AM
Add validation using sheet code Gareth[_4_] Excel Programming 6 October 18th 03 12:59 AM
Validation of time in code Steve Rolls Excel Programming 6 September 5th 03 09:17 PM


All times are GMT +1. The time now is 02:18 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"