Date Validation

D

danamyc

Hi

Is there anyway to validate a date to ensure that the date enetred in
cell
B2 is a Monday?

Also how would it be coded to ensure that if a Monday was not entered
then
it returned a error message.

Thanks
 
G

Glenn

danamyc said:
Hi

Is there anyway to validate a date to ensure that the date enetred in
cell
B2 is a Monday?

Also how would it be coded to ensure that if a Monday was not entered
then
it returned a error message.

Thanks


Select cell B2. Go to Data / Validation.


Settings Tab


Allow: Custom

Formula: =WEEKDAY(B2)=2



Error Alert Tab


Show error alert after invalid data is entered (check)

Style: Stop

Error message: That's not a Monday!
 
D

danamyc

Brillant thank you very much.

Sorry to be a pain but what would code be for the smae formula but for
a sunday.

Thanks
Dan
 
G

Glenn

danamyc said:
Brillant thank you very much.

Sorry to be a pain but what would code be for the smae formula but for
a sunday.

Thanks
Dan


Look here:

http://www.cpearson.com/Excel/datetime.htm


Or, just check out the WEEKDAY function in the help file.


WEEKDAY

Returns the day of the week corresponding to a date. The day is given as an
integer, ranging from 1 (Sunday) to 7 (Saturday), by default.

Syntax

WEEKDAY(serial_number,return_type)

Serial_number is a sequential number that represents the date of the day you are
trying to find. Dates should be entered by using the DATE function, or as
results of other formulas or functions. For example, use DATE(2008,5,23) for the
23rd day of May, 2008. Problems can occur if dates are entered as text.


Return_type is a number that determines the type of return value.


Return_type Number returned

1 or omitted Numbers 1 (Sunday) through 7 (Saturday).
Behaves like previous versions of Microsoft Excel.

2 Numbers 1 (Monday) through 7 (Sunday).

3 Numbers 0 (Monday) through 6 (Sunday).
 

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