Link to home
Start Free TrialLog in
Avatar of Dave Kong
Dave KongFlag for United States of America

asked on

How Can I Change Tab Color if Any Change is Made to a Worksheet?

I have created a Work Slip in Excel.  I have broken it into separate worksheets so it doesn't overwhelm the user having everything on one sheet.

I want to create a macro that will change the tab color for a sheet if that sheet is revised in any way.  I found some code that changes the tab color based on a cell value, so I think this is possible, but I am not sure how to make it trigger if anything on the sheet changes.

Code that changes the tab color based on a cell value (as an example):

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("B9").Value <> 0 Then
    Me.Tab.ColorIndex = 3
Else
    Me.Tab.ColorIndex = xlColorIndexNone
End If
End Sub
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

This will change the tab colour when anything changes...

Private Sub Worksheet_Change(ByVal Target As Range)
     Me.Tab.ColorIndex = 3
End Sub

Open in new window

Avatar of Dave Kong

ASKER

That is elegantly simple!  I will try this out as soon as I can.  Thank you!
Question:  Where exactly do I put this code?

Dave
Right-click on the sheet tab and select "View code". Put the code in this module.
I put the code in the module.  When is it supposed to trigger?  I made changes to that sheet but the tab did not change.
It will change whenever a cell's value is changed. Attached is an example. I've also put code into the ThisWorkbook module which clears all tab colours when the workbook is saved.
E--Book1.xlsm
I see it working now!  I was originally selecting a checkbox on the page.  Selecting a checkbox won't trigger it?
ASKER CERTIFIED SOLUTION
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you for the response.  I am unfortunately cranking today in preparation for vacation.  I may not be able to look at this further until I return on the 13th.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.