Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default 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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 698
Default 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.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 04:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"