VBA to change tab color if range of cells has any input

FatalaniSnape

New Member
Joined
Jul 28, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
I have a table of names, phone numbers, emails. There are drop downs in two of the columns, but no formulas.
I need the tab color to change if any information is entered between Cells A2 and G26.
I've found codes for specific values or text, but this needs to be for anything entered.

TIA
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Try this in that worksheet's code module. Change the sheet name to your sheet name, of course. And you can pick another color index to suit (255 = red, xlAutomatic = no color).
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If WorksheetFunction.CountA(Range("A2:G26")) > 0 Then
    Sheets("Sheet1").Tab.Color = 255
Else
    Sheets("Sheet1").Tab.Color = xlAutomatic
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,004
Messages
6,122,656
Members
449,091
Latest member
peppernaut

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