Excel宏 - 如何在同一工作簿中的单独工作表中基于单元格更改选项卡颜色?

时间:2017-02-01 15:21:59

标签: excel vba excel-vba

我尝试了以下内容并且它没有工作 - 任何其他建议?

msbuild /toolsversion:14.0 MyProject.HelloWorld.proj

1 个答案:

答案 0 :(得分:0)

Private Sub Worksheet_Change(ByVal Target As Range)
Dim MyVal$
MyVal = ActiveWorkbook.Sheets("Summary").Range("A8")

With ActiveSheet.Tab
    Select Case MyVal
        Case "Black"
            .Color = vbBlack
        Case "Red"
            .Color = vbRed
        Case "Green"
            .Color = vbGreen
        Case "Yellow"
            .Color = vbYellow
        Case "Blue"
            .Color = vbBlue
        Case "Magenta"
            .Color = vbMagenta
        Case "Cyan"
            .Color = vbCyan
        Case "White"
            .Color = vbWhite
        Case Else
            .ColorIndex = xlColorIndexNone
    End Select
End With
End Sub