How to Automatically Hide Weekends and Highlight Weekdays in Excel
Question details
The user needs to automatically hide Saturdays and Sundays while applying distinct color highlights to specific weekdays (Mondays and Fridays in one color, Tuesdays through Thursdays in another) across a three-month worksheet.
- Product
- Excel
- Device & OS
- not provided
- Scenario
- Setting up a multi-month schedule, tracker, or calendar where non-working days are hidden and specific working days are color-coded for visual clarity.
- Observed behavior
- The goal state is to have weekends fully hidden from view and workdays automatically formatted with specific colors based on the exact day of the week.
Ensure your worksheet is saved as a Macro-Enabled Workbook (.xlsm) since automatically hiding rows requires VBA, and test the code on a sample copy of your data before applying it to your main file.
Highlight Weekdays using Conditional Formatting
Use Excel's built-in Conditional Formatting with the WEEKDAY function to automatically color-code Mondays/Fridays and Tuesdays-Thursdays.
Conditional formatting dynamically changes the appearance of cells based on their values. By combining it with the WEEKDAY function, you can identify the exact day of the week and assign the corresponding background colors.
Highlight the entire range of dates you want to format across your three-month worksheet.
Navigate to the Home tab on the ribbon, click on 'Conditional Formatting', and choose 'New Rule'.
Select 'Use a formula to determine which cells to format'. Enter the formula =OR(WEEKDAY(A1)=2, WEEKDAY(A1)=6) (assuming A1 is the first cell in your range). Click 'Format', choose your preferred color for Mondays and Fridays, and click 'OK'.
Create another rule using the formula =AND(WEEKDAY(A1)>=3, WEEKDAY(A1)<=5). Click 'Format', pick a different background color, and apply the rule.
Automatically Hide Weekends using a VBA Macro
Since native Conditional Formatting cannot hide entire rows, use a VBA macro to scan the date column and automatically hide rows falling on a Saturday or Sunday.
Easily Format and Manage Calendars with WPS Spreadsheet
WPS Spreadsheet offers comprehensive support for advanced Conditional Formatting and VBA macros (in supported versions), allowing you to seamlessly set up complex tracking sheets and automatically hide weekends.
- 1. Open your file in WPS Spreadsheet: Launch WPS Office and open your project tracker or calendar workbook.
- 2. Apply Conditional Formatting: Highlight your dates, navigate to the Home tab, and select Conditional Formatting to input your WEEKDAY formulas.
- 3. Run your formatting macros: Access the Developer tab, open the VBA editor, and insert your row-hiding script for weekend automation.
- 4. Save with Macro support: Save your document as a Macro-Enabled Workbook to preserve your scripts for future use.

Frequently Asked Questions
Can I hide weekends in Excel without using VBA macros?
Excel does not have a built-in feature to automatically hide rows purely based on cell values without VBA. However, you can use the Filter tool on your date column to manually uncheck Saturdays and Sundays, which effectively hides them from view.
What does the WEEKDAY function do in Excel?
The WEEKDAY function returns a number from 1 to 7 that corresponds to the day of the week for a specific date. By default, 1 represents Sunday and 7 represents Saturday. It is widely used in conditional formatting and date calculations.
Why is my conditional formatting applying to the wrong rows?
This commonly happens if the cell reference in your formula does not match the active cell of your selected range. Always make sure you are referencing the top-left cell of your selection, and check whether you are incorrectly using absolute references (like $A$1 instead of A1).
How do I unhide the weekend rows once the VBA macro runs?
You can manually unhide them by selecting the entire worksheet (clicking the triangle in the top-left corner), right-clicking any row number, and selecting 'Unhide'. Alternatively, you can create a second macro that sets EntireRow.Hidden = False to quickly unhide all rows.




