ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Count and report the number of red colored cells in a row (https://www.excelbanter.com/excel-programming/452774-count-report-number-red-colored-cells-row.html)

[email protected]

Count and report the number of red colored cells in a row
 
Hello,

I like to get a module which gives me the number of background red colored cells within each row (a loop)

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.

If in the first range 1 cell is colored red and in the other range 3 cells, then in this row column B should be reported 1+3 - 4.

If somebody can help me out.

THANKS.

regards, Johan

Claus Busch

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

bulong

Mua sắm an to*n v* tiện lợi với hình thức giao h*ng nh*n tiền của chúng tôi. Mọi thứ bạn cần được đưa đến b*c c*a nh* bạn chỉ sau 1 cú nhấp chuột
_________________
kinky videos

https://t.co/3x41dVyRLl

[email protected]

Count and report the number of red colored cells in a row
 
On Saturday, November 19, 2016 at 9:14:30 AM UTC+1, wrote:
Hello,


SuperThanks. Works !!

regards,
Johan


All times are GMT +1. The time now is 01:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com