A user enters:
1) The Start date of the month in Cell B1
2) The joining date (in case of a new employee) in Cell B2
3) Number of days worked in the current month in Cell B3 which has a custom data validation check as follows:
which is to make sure that the no. of days worked do not exceed the total no. of days available in that month, from the start of the month or, from the joining date -in case of a new employee.
This Data validation check works if there is a joining date, but it fails to restrict an incorrect value if the joining date (cell B2) is blank.
The same custom validation Formula in Cell B4 works correctly even when the joining date is blank. But somehow fails to work in a data validation.
How can I fix the data validation to work correctly?
1) The Start date of the month in Cell B1
2) The joining date (in case of a new employee) in Cell B2
3) Number of days worked in the current month in Cell B3 which has a custom data validation check as follows:
=AND(OR(MOD(B3,1)=0.5,MOD(B3,1)=0),B3>=0,B3<=(DAY(EOMONTH(B1,0))-IF(B2=0,DAY(B1),DAY(B2))+1))
which is to make sure that the no. of days worked do not exceed the total no. of days available in that month, from the start of the month or, from the joining date -in case of a new employee.
This Data validation check works if there is a joining date, but it fails to restrict an incorrect value if the joining date (cell B2) is blank.
The same custom validation Formula in Cell B4 works correctly even when the joining date is blank. But somehow fails to work in a data validation.
How can I fix the data validation to work correctly?
Book1 | |||||
---|---|---|---|---|---|
A | B | C | |||
1 | Enter the Beginning Date of this month: | 1-Jul-23 | ← this month has 31 days | ||
2 | Enter the Joining Date (for new employees) : | ← so when this is Blank (no joining date) | |||
3 | Days Worked in this month (including half working days) : | 32 | ← Custom Data Validation accepted this value | ||
4 | Data Validation criteria in Cell B3 : | FALSE | ← however the Formula used in above Custom Data Validation triggers False | ||
Sheet1 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
B4 | B4 | =AND(OR(MOD(B3,1)=0.5,MOD(B3,1)=0),B3>=0,B3<=(DAY(EOMONTH(B1,0))-IF(B2=0,DAY(B1),DAY(B2))+1)) |
Cells with Data Validation | ||
---|---|---|
Cell | Allow | Criteria |
B2 | Date | between B1 and EOMONTH(B1,0) |
B3 | Custom | =AND(OR(MOD(B3,1)=0.5,MOD(B3,1)=0),B3>=0,B3<=(DAY(EOMONTH(B1,0))-IF(B2=0,DAY(B1),DAY(B2))+1)) |