Thread
:
Count and report the number of red colored cells in a row
View Single Post
#
2
Posted to microsoft.public.excel.programming
Claus Busch
external usenet poster
Posts: 3,872
Count and report the number of red colored cells in a row
Hi Johan,
Am Sat, 19 Nov 2016 00:14:23 -0800 (PST) schrieb
:
Row 2 till last
The number of red colored cells in this row to report in column B.
The range to look at is in active row column C till F and in the same row also in column K till S.
try:
Sub CountColor()
Dim myRng As Range, rngC As Range
Dim LRow As Long, i As Long, Counter As Long
With ActiveSheet
LRow = .Cells(.Rows.Count, "C").End(xlUp).Row
Set myRng = .Range("C2:F" & LRow & ",K2:S" & LRow)
For i = 2 To LRow
Counter = 0
For Each rngC In Intersect(myRng, Rows(i))
If rngC.Interior.Color = vbRed Then
Counter = Counter + 1
End If
Next
.Cells(i, "B") = Counter
Next
End With
End Sub
Regards
Claus B.
--
Windows10
Office 2016
Reply With Quote
Claus Busch
View Public Profile
Find all posts by Claus Busch