Reputation: 11
I need a help. with this code:
Sub Worksheet_Change(ByVal Target As Range)
Dim ws As Worksheet
For Each ws In Workbooks("Book1.xlsm").Worksheets
If ws.Target.Address = "$A$1" Then
Select Case Target.Value
Case Is <> ""
Me.Tab.Color = vbGreen
Case ""
Me.Tab.Color = vbWhite
Case Else
Me.Tab.Color = vbBlue
End Select
End If
End Sub
It is not working, but I don't know why. Any ideas? Thanks in advance.
Upvotes: 0
Views: 68
Reputation: 9568
In ThisWorkbook module put the code like that
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Address = "$A$1" Then
Select Case Target.Value
Case Is <> ""
Sh.Tab.Color = vbGreen
Case ""
Sh.Tab.Color = vbWhite
Case Else
'This will not happen as it is either empty or non-empty
Sh.Tab.Color = vbBlue
End Select
End If
End Sub
Upvotes: 2