Automatic tab colour change when cell populated

Bazz1974

New Member
Joined
Mar 30, 2021
Messages
2
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
I having been going mad trying to find a macro to easily change the worksheet tab colors as each worksheet is populated in a set cell.
say if I entered text or date in C1, the tab colour on that worksheet turns red, otherwise is green.

I have tried so many different code and nothing will work.
There are 25 worksheets in the workbook and all numbered from 1 to 25 plus 2 others named "Lists" and "Summary" (these 2 dont need the tab colours. When you open the workbook, Id like tabs 1 to 25 to be green and once C1 has a entry, the tab for that sheet turns red. This is so the next person opening the book knows which tab has no entries as yet.

Appreciate if someone can help here.

1617104186894.png
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,644
Office Version
  1. 365
Platform
  1. Windows
If you change all the tab colours to what they should be, you can then use this
VBA Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
   If Target.CountLarge > 1 Then Exit Sub
   Select Case Sh.Name
      Case "Lists", "Summary"
      Case Else
         If Target.Address(0, 0) = "C1" Then
            Sh.Tab.Color = IIf(Target.Value = "", rgbGreen, vbRed)
         End If
   End Select
End Sub
This needs to go in the ThisWorkbook module.
 

Bazz1974

New Member
Joined
Mar 30, 2021
Messages
2
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Thankyou so much. that worked a treat. I'll send it out to the gang and report back if any other issues.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,644
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,751
Messages
5,638,154
Members
417,010
Latest member
jnuss03

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top