change tab colour when using conditional formatting in a cell

G

Guest

how can I change a tab to colour to highlight a problem without going into an
actual worksheet to work on
 
G

Gord Dibben

You cannot use CF to change a Tab color.

You would need VBA.

Either event code or just a macro.

Sub test()
If Sheets("Sheet2").Range("A1").Value <> "hello" Then
Sheets("Sheet1").Tab.ColorIndex = 6
Else
Sheets("Sheet1").Tab.ColorIndex = -4142
End If
End Sub


Gord Dibben MS Excel MVP
 
G

Guest

Gord Dibben said:
You cannot use CF to change a Tab color.

You would need VBA.

Either event code or just a macro.

Sub test()
If Sheets("Sheet2").Range("A1").Value <> "hello" Then
Sheets("Sheet1").Tab.ColorIndex = 6
Else
Sheets("Sheet1").Tab.ColorIndex = -4142
End If
End Sub


Gord Dibben MS Excel MVP



can you take me through this as I don't know how to
 
G

Guest

that is great but how do i do that???

Gord Dibben said:
You cannot use CF to change a Tab color.

You would need VBA.

Either event code or just a macro.

Sub test()
If Sheets("Sheet2").Range("A1").Value <> "hello" Then
Sheets("Sheet1").Tab.ColorIndex = 6
Else
Sheets("Sheet1").Tab.ColorIndex = -4142
End If
End Sub


Gord Dibben MS Excel MVP
 
G

Gord Dibben

If not familiar with VBA and macros, see David McRitchie's site for more on
"getting started".

http://www.mvps.org/dmcritchie/excel/getstarted.htm

In the meantime..........

First...create a backup copy of your original workbook.

To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

Hit CRTL + R to open Project Explorer.

Find your workbook/project and select it.

Right-click and Insert>Module. Paste the code in there. Save the
workbook and hit ALT + Q to return to your workbook.

Run the macro by going to Tool>Macro>Macros.

You can also assign this macro to a button or a shortcut key combo.


Gord Dibben MS Excel MVP



Gord Dibben MS Excel MVP
 
G

Guest

Hit ALT+ F11 and cop and paste Gord's code into the white space on the right
hand side of the window that appears. Hit save and close out of that window.
Now, if A1 contains something other than "Hello" you will see the tab color
for that sheet1 change.

Change the cell and sheet reference as appropriate for your sitatuation.

Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top