0

This code runs for 3 seconds without error. but i get no results. i should have over 1000 in count with font color red.

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
Rubén
  • 34,714
  • 9
  • 70
  • 166
Byron
  • 61
  • 1
  • 11
  • also font color is set with conditional formatting. – Byron Oct 30 '19 at 22:55
  • 1
    Can you post some sample data? I've tested the code and it actually counts the cells correctly. – Ricardo Diaz Oct 31 '19 at 01:00
  • As conditional formatting is topical and the color of the cell is what is beneath the veneer, you will most likely need to check if the cell is conditionally formatted, or run your code to count where the same criteria as the conditional formatting is true. – Cyril Oct 31 '19 at 13:54
  • Additionally, see [this post](https://stackoverflow.com/a/24338126/3233363) abotu some possibilities – Cyril Oct 31 '19 at 13:57
  • how can i post a screenshot? or can i? – Byron Nov 01 '19 at 13:36
  • [Edit](https://stackoverflow.com/posts/58634676/edit) the question and if you’re on windows use ctrl + win + s and then on the post paste it directly – Ricardo Diaz Dec 18 '19 at 03:53

0 Answers0