View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
FSt1 FSt1 is offline
external usenet poster
 
Posts: 3,942
Default if fill color = this, then increment this cell by one

hi,
see this site for color indexes. only 7 colors have names. all the other
have index numbers.
http://www.mvps.org/dmcritchie/excel/colors.htm

i have a problem with the Range("C4:AF5").
I hope you haven't scattered these colors throught out the range and are
expecting this code to count all the colors. if so, then you will need a for
next loop to loop through the range and look at each cell color individually.
Post back with more info.

regards
FSt1
"forbes" wrote:

Here is my first attempt

Private Sub changeColor()
Dim x As Integer
Dim y As Integer
Dim z As Integer


Set myfrange = Sheet1.Range("AI:5").Value = x
Set myyrange = Sheet1.Range("AK:5").Value = y
Set myzrange = Sheet1.Range("AK:5").Value = z


If Range("C4:af5").Cells.Interior.Color.[Red] Then x = x + 1
If Range("C4:af5").Cells.Interior.Color.[Magenta] Then y = y + 1
If Range("C4:af5").Cells.Interior.Color.[Black] Then z = z + 1

This doesn't work. Any ideas?
Thanks