Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|