ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Any formula to count number of cells with a specific color pattern (https://www.excelbanter.com/excel-worksheet-functions/166388-any-formula-count-number-cells-specific-color-pattern.html)

Stu

Any formula to count number of cells with a specific color pattern
 
Is there any formula to count the number of cells (and total the numerical
content of those cells) with a specific color pattern?

Gary''s Student

Any formula to count number of cells with a specific color pattern
 
Yes see:
http://www.cpearson.com/excel/colors.htm

--
Gary''s Student - gsnu200756


"Stu" wrote:

Is there any formula to count the number of cells (and total the numerical
content of those cells) with a specific color pattern?


ryguy7272

Any formula to count number of cells with a specific color pat
 
This function should give you what you want:
Sub countcolor()
Dim rng As Range
Dim cnt As Long

Set rng = Range("A1:E12")
cnt = 0
For Each cell In rng
If cell.Interior.ColorIndex = 3 Then
cnt = cnt + 1
End If
Next
MsgBox cnt
'or Range("K2").Value = cnt
Range("G1").Value = cnt
End Sub

Notice, it is set up to count the number of cells that are colored red:
cell.Interior.ColorIndex = 3

Look here for other Excel color IDs:
http://www.geocities.com/davemcritchie/excel/colors.htm


Regards,
Ryan---

--
RyGuy


"Gary''s Student" wrote:

Yes see:
http://www.cpearson.com/excel/colors.htm

--
Gary''s Student - gsnu200756


"Stu" wrote:

Is there any formula to count the number of cells (and total the numerical
content of those cells) with a specific color pattern?



All times are GMT +1. The time now is 06:50 PM.

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