Conditional tab formatting?
This I saw Bob Phillips' code to automatically name a
worksheet based on a cell in the worksheet (reprinted below). Is there also a code to automatically select the tab color based on a condition in the worksheet. Specifically, if a report is marked "AR" I want the tab red, "CSR" is yellow and Green for "SQ". Also, is there a way to alpha sort the worksheets in a workbook? Thanks for your help. Code to name the woksheet with the value in G1: Private Sub Worksheet_Change(ByVal Target As Range) On Error GoTo ws_exit: Application.EnableEvents = False If Target.Address = "$G$1" Then Me.Name = Target.Value End If ws_exit: Application.EnableEvents = True End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. |
OK, I found it myself, sort and TOC IS better than color.
http://www.mvps.org/dmcritchie/excel....htm#sortallsh eets -----Original Message----- This I saw Bob Phillips' code to automatically name a worksheet based on a cell in the worksheet (reprinted below). Is there also a code to automatically select the tab color based on a condition in the worksheet. Specifically, if a report is marked "AR" I want the tab red, "CSR" is yellow and Green for "SQ". Also, is there a way to alpha sort the worksheets in a workbook? Thanks for your help. Code to name the woksheet with the value in G1: Private Sub Worksheet_Change(ByVal Target As Range) On Error GoTo ws_exit: Application.EnableEvents = False If Target.Address = "$G$1" Then Me.Name = Target.Value End If ws_exit: Application.EnableEvents = True End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. . |
All times are GMT +1. The time now is 04:44 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com