我需要帮助。使用此代码:
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
它不起作用,但我不知道为什么。有什么想法吗?提前谢谢。
在ThisWorkbook模块中放入类似的代码
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