ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Please help. (https://www.excelbanter.com/excel-programming/350605-please-help.html)

Steven

Please help.
 
I need to create a macro does some addition.
For example, I will have some green colored cells in Column A, and I
want C4 displays the total number of green cells in column A.
Thank you for taking your valuable time to read this. Any help would be
appreciated.


Norman Jones

Please help.
 
Hi Steven,

See Chip Pearson's page on counting and summing by colour at:

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

See also XlDynamic at:

http://www.xldynamic.com/source/xld.....html#counting


---
Regards,
Norman


"Steven" wrote in message
ups.com...
I need to create a macro does some addition.
For example, I will have some green colored cells in Column A, and I
want C4 displays the total number of green cells in column A.
Thank you for taking your valuable time to read this. Any help would be
appreciated.




L. Howard Kittle

Please help.
 
Hi Steven,

Chip's site will have everything you need and more, but you can give this a
try.

Sub SumColorCountGreen()
Dim Green4 As Integer
Dim Cell As Range
'For Each Cell In Range("Data")
For Each Cell In Range("A1:A100")
If Cell.Interior.ColorIndex = 4 Then
Green4 = Green4 + Cell.Value
End If
Next

'Range("C4").Value = "Green = " & Green4
Range("C4").Value = Green4

MsgBox " Green adds to " & Green4, _
vbOKOnly, "CountColor"
End Sub

You can use either of these For statements. You will have to name your
range "Data" for the first one or set the range to suit your sheet for the
second.

For Each Cell In Range("Data")
For Each Cell In Range("A1:A100")

HTH
Regards,
Howard

"Steven" wrote in message
ups.com...
I need to create a macro does some addition.
For example, I will have some green colored cells in Column A, and I
want C4 displays the total number of green cells in column A.
Thank you for taking your valuable time to read this. Any help would be
appreciated.





All times are GMT +1. The time now is 03:45 AM.

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