Change tab color based on formula

Sammi8796

Board Regular
Joined
Dec 12, 2007
Messages
100
Office Version
  1. 2016
Platform
  1. Windows
I wanted to know if you can change the color of a tab based on the contents of a cell by using a formula? The contents of the cell are returned from a basic formula. The number would either be a positive number or a negative number. I wanted the tab to turn red if the cell returned a negative number or stay the same if it returned anything over "0."
Example: cell O32 contents are 372, therefore the tab stays the same. Cell O32 contents are -23, therefore I want the tab to turn red. Any help would be appreciated. Thanks!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Put this code into your worksheet:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("A1").Value < 0 Then
    ActiveSheet.Tab.ColorIndex = 3
Else
    ActiveSheet.Tab.ColorIndex = 2
End If
End Sub
 
Upvote 0
Forgive me, I'm not at all familiar with code...where am I putting this? And would I need to insert this into each tab? Thanks again.
 
Upvote 0
I think I found the window that I should enter it in VBA. I did that but I'm not seeing any results. Anything that you can point me in the right direction would be appreciated.
 
Upvote 0

Forum statistics

Threads
1,224,537
Messages
6,179,405
Members
452,911
Latest member
a_barila

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
Back
Top