How to Change Excel Sheet Tab Colors Based on Cell Values
Question details
The user needs to automatically update worksheet tab colors based on specific lookup values (Red or Yellow) present in a control sheet.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Tracking multiple worksheets where a master control sheet determines the status of each sheet. Column B contains the exact worksheet names, and Column E contains formula-driven status values that dictate the required tab color.
- Observed behavior
- The user wants the sheet tabs to dynamically turn red or yellow when the corresponding formula-based cell value in Column E updates.
Ensure that your workbook is saved as an Excel Macro-Enabled Workbook (.xlsm) and verify that the sheet names listed in your control column exactly match the actual tab names, with no extra spaces.
Use a VBA Worksheet_Activate or Calculate Event
Implement a VBA macro on your control sheet to loop through the designated column and update the corresponding tab colors automatically.
Since standard Conditional Formatting cannot be applied to worksheet tabs, a VBA macro is required. Because the values in Column E are driven by formulas from another sheet, a standard Worksheet_Change event might not trigger. Using a Worksheet_Activate or Worksheet_Calculate event ensures the tab colors refresh whenever the control sheet is viewed or its formulas recalculate.
Press Alt + F11 on your keyboard to open the Visual Basic for Applications window in Excel.
In the Project Explorer pane on the left side, locate your current workbook and double-click the specific sheet module (e.g., Sheet1) that contains your list of names in Column B and status values in Column E.
At the top of the code window, select 'Worksheet' from the left dropdown menu and 'Activate' (or 'Calculate') from the right dropdown menu.
Inside the procedure, write a For loop that iterates through your data rows. For each row, read the sheet name from Column B. Check the value in Column E; if it equals 'Red', use the command Sheets(sheetName).Tab.Color = vbRed. If it equals 'Yellow', set it to vbYellow. If it is 'Green' or empty, use xlColorIndexNone to clear the color.
Save your workbook. Return to the Excel interface. Click on a different sheet tab, then click back onto your control sheet. The Worksheet_Activate event will run, instantly applying the correct colors to all matching tabs.

Use WPS Spreadsheet to Run VBA Macros and Manage Workbooks
WPS Spreadsheet offers powerful built-in support for VBA macros in its advanced editions, allowing you to easily run customized scripts to change tab colors, automate repetitive tasks, and streamline your workflow just like in Microsoft Excel.
- 1. Open Your Workbook in WPS: Launch WPS Spreadsheet and open your .xlsm file containing the control sheet data.
- 2. Access Developer Tools: Click on the 'Developer' tab on the top ribbon. If you do not see it, enable it in your WPS settings.
- 3. Launch the VBA Editor: Click the 'Visual Basic' icon to open the code editor. Double-click your control sheet module in the project explorer.
- 4. Paste and Run Code: Insert your Worksheet_Activate macro to assign tab colors based on cell values, then save the document.

Frequently Asked Questions
Why does my VBA macro return a 'Subscript out of range' error?
This error typically occurs when the macro tries to find a sheet name that doesn't exist. Ensure that the text in Column B exactly matches the actual sheet tab name, paying close attention to trailing or leading spaces.
Can I change worksheet tab colors using Excel Conditional Formatting instead of VBA?
No. Excel's built-in Conditional Formatting feature only applies to cells inside the grid. Modifying the properties of worksheet tabs dynamically requires VBA.
How do I remove the tab color using VBA?
To remove a tab color in your VBA code, set the ColorIndex property of the tab to none by using the syntax: Sheets("SheetName").Tab.ColorIndex = xlColorIndexNone.
Why doesn't the Worksheet_Change event trigger when my formula updates?
The Worksheet_Change event only triggers when a user manually edits a cell. If your cell value changes because a formula recalculated, you must use the Worksheet_Calculate event to trigger your macro.




