You are learning Data Validation in MS Excel
How to use data validation to prevent data entry on weekends or holidays?
![](https://static.wixstatic.com/media/ce4386_94a468693f7f46e9b49d1eec8244674a~mv2.png/v1/fill/w_980,h_551,al_c,q_90,usm_0.66_1.00_0.01,enc_avif,quality_auto/Kepler%20Works_%20Googlexcel_com_%20Kepler's%20Library%20-%20Knowledge%20Based%20for%20Excel%2C%20Data%2C%20and%20AI_%20.png)
Here's how to use data validation to prevent data entry on weekends and holidays in Excel:
1. Define Holiday List (Optional):
- If you have a specific list of holidays, create a list of dates in a separate area of your worksheet (e.g., A1:A10).
2. Select Cell for Validation:
- Click on the cell where you want to restrict weekend and potentially holiday entries.
3. Data Validation Menu:
- Go to the "Data" tab on the Excel ribbon.
- In the "Data Tools" group, click on "Data Validation."
4. Set Allow to Custom Formula:
- In the "Settings" tab of the Data Validation window, under "Allow," choose "Custom formula" from the dropdown menu.
5. Enter Validation Formula:
- In the "Formula" box, enter the following formula:
```excel
=AND(WEEKDAY(A1,2)<6,ISNA(MATCH(A1,$L:$L,0)))
```
Explanation of the Formula:
- `WEEKDAY(A1,2)`: This part checks the weekday of the entered date in cell A1. We use `2` as the second argument to set the week to start on Monday (1-Sunday, 2-Monday, etc.).
- `<6`: This compares the weekday number (1-7) to 6. If less than 6, it's a weekday (Monday-Friday).
- `ISNA(MATCH(A1,$L:$L,0))`: This part checks if the entered date (A1) exists in the holiday list (range $L:$L, replace with your actual holiday list range). `ISNA` checks for errors, so `ISNA(MATCH(...))` will return TRUE if there's no match (not a holiday), and FALSE if it's a holiday.
- `AND`: The entire formula uses the `AND` logical operator. The data is valid only if BOTH conditions are met: it's a weekday AND it's not a holiday (or there's no holiday list).
6. Set Error Message (Optional):
- In the "Input Message" tab, you can enter a message to be displayed when users hover over the cell. (e.g., "Dates must be weekdays and not holidays").
- In the "Error Alert" tab, you can create a custom error message to be displayed if an invalid date is entered. (e.g., "Invalid Date: Weekends and holidays are not allowed").
7. Click OK:
- Click "OK" to close the Data Validation window.
With this setup, Excel will only allow dates that are weekdays and not on your holiday list (if provided). If a user tries to enter a weekend date or a holiday, they will receive an error message based on your settings.