如何使用条件格式字体颜色计数单元格

时间:2019-10-30 22:51:01

标签: excel vba counter conditional-formatting

此代码运行3秒钟,没有错误。但我没有结果。 我应该有超过1000种红色的字体。

Sub Count_Flanges()

    Application.ScreenUpdating = False

    Dim Rng As Range
    Dim lColorCounter As Long
    Dim rngCell As Range

    Set Rng = Sheets("master line list").Range("C2:Z1633")

    lColorCounter = 0

    For Each rngCell In Rng
        If Cells(rngCell.Row, rngCell.Column).DisplayFormat.Font.Color = RGB(255, 0, 0) Then
            lColorCounter = lColorCounter + 1
        End If
    Next

    Sheets("status").Range("D3") = lColorCounter
    Sheets("status").Range("A1") = lColorCounter / 2 & " " & "Total Duplicates"
    Sheets("status").Range("A2") = Sheets("status").Range("D5").Value - lColorCounter / 2 & " " & "Flanges"

    Application.ScreenUpdating = True

End Sub

0 个答案:

没有答案