VBA Change color of sheet Tab if range of cells has text

JoeHo

New Member
Joined
Jul 22, 2021
Messages
2
Office Version
  1. 2013
Platform
  1. Windows
Hey,

I am currently trying to get a code work that changes me the color of the tab to green if the cells are empty and if the cells contain text or numbers, the tab color gets red. This is meant to show people that look into the file, which tab they need to check.

I tried already a lot but could not make it happen.

Thanks in advance!
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
This sub will do it for you, you need to decide what is going to trigger it to run, you could run it when the workbook opens,
Also you haven't specified what range you want to check , so it is checking A1 on sheet1
VBA Code:
Sub test2()
With Worksheets("sheet1")

 If (.Cells(1, 1)) = "" Then
  With .Tab
        .Color = 5296274
        .TintAndShade = 0
  End With
 Else
     With .Tab
           .Color = 255
           .TintAndShade = 0
     End With
    End If
 
End With
End Sub
 
Upvote 0
Solution
This sub will do it for you, you need to decide what is going to trigger it to run, you could run it when the workbook opens,
Also you haven't specified what range you want to check , so it is checking A1 on sheet1
VBA Code:
Sub test2()
With Worksheets("sheet1")

 If (.Cells(1, 1)) = "" Then
  With .Tab
        .Color = 5296274
        .TintAndShade = 0
  End With
 Else
     With .Tab
           .Color = 255
           .TintAndShade = 0
     End With
    End If
 
End With
End Sub
Thanks a lot for your help!
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,113,998
Members
448,539
Latest member
alex78

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