Z
Zenaida
Does anyone know what code I would use in the worksheet event to chang
the tab color of all 6 worksheets in my workbook based off a value in
cell?
I would like all 6 tabs to be red if there is any value in cell V1 o
worksheet 1. If cell V1 is empty I don't want any tab color.
I'm also not sure how to reference worksheet 1 in the code because th
name of it changes depending on what's in two other cells of th
worksheet.
This is the code I have right now in the worksheet event.
Code
-------------------
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ws As Worksheet
Dim i As Long
If InStr(Target.Address, "$A$7") <> 0 Or InStr(Target.Address, "$A$8") <> 0 Then
For Each ws In Worksheets
i = i + 1
On Error Resume Next
If Not IsDate(Range("A7")) Then
ws.Name = "Cert Period " & i
Else
ws.Name = Format(ws.Range("A7"), "m-dd-yy") & " THRU " & Format(ws.Range("F7"), "m-dd-yy")
End If
If Err.Number <> 0 Then
MsgBox "Could not rename sheet " & ws.Name, vbCritical, "Renaming Error"
Err.Clear
End If
Next ws
End If
End Su
-------------------
(FYI - cells A7 & F7 are merged cells.)
Any help is greatly appreciated. Thanks
+-------------------------------------------------------------------
|Filename: Frequency Audit.zip
|Download: http://www.excelforum.com/attachment.php?postid=4696
+-------------------------------------------------------------------
the tab color of all 6 worksheets in my workbook based off a value in
cell?
I would like all 6 tabs to be red if there is any value in cell V1 o
worksheet 1. If cell V1 is empty I don't want any tab color.
I'm also not sure how to reference worksheet 1 in the code because th
name of it changes depending on what's in two other cells of th
worksheet.
This is the code I have right now in the worksheet event.
Code
-------------------
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ws As Worksheet
Dim i As Long
If InStr(Target.Address, "$A$7") <> 0 Or InStr(Target.Address, "$A$8") <> 0 Then
For Each ws In Worksheets
i = i + 1
On Error Resume Next
If Not IsDate(Range("A7")) Then
ws.Name = "Cert Period " & i
Else
ws.Name = Format(ws.Range("A7"), "m-dd-yy") & " THRU " & Format(ws.Range("F7"), "m-dd-yy")
End If
If Err.Number <> 0 Then
MsgBox "Could not rename sheet " & ws.Name, vbCritical, "Renaming Error"
Err.Clear
End If
Next ws
End If
End Su
-------------------
(FYI - cells A7 & F7 are merged cells.)
Any help is greatly appreciated. Thanks
+-------------------------------------------------------------------
|Filename: Frequency Audit.zip
|Download: http://www.excelforum.com/attachment.php?postid=4696
+-------------------------------------------------------------------