Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Geni Slaughter
 
Posts: n/a
Default need help with countIF and CountByColor functions~~

OK, I got this code from a previous post, and it works great.
Now what I want to do is have the function check to see if the cell has a
"D" in it or not. If it does, continue and add to the count if the color
matches. If not, go on to the next cell.
Make sense???
I tried to edit this myself and could not.
Here is the function code I'm using:

Function CountByColor(InRange As Range, _
WhatColorIndex As Integer, _
Optional OfText As Boolean = False) As Long
'
' This function return the number of cells in InRange with
' a background color, or if OfText is True a font color,
' equal to WhatColorIndex.
'
Dim Rng As Range
Application.Volatile True

For Each Rng In InRange.Cells
If OfText = True Then
CountByColor = CountByColor - _
(Rng.Font.ColorIndex = WhatColorIndex)
Else
CountByColor = CountByColor - _
(Rng.Interior.ColorIndex = WhatColorIndex)
End If
Next Rng

End Function


So I want it to test the cell first for the letter D and then see if it's
the certain color.

Thanks for your help!!
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
countif statement Russell Hampton Excel Worksheet Functions 6 December 18th 04 07:39 PM
Countif - Countif maswinney Excel Worksheet Functions 3 November 15th 04 11:06 PM
Countif ??? terryv Excel Worksheet Functions 2 November 8th 04 09:03 AM
Countif, Sumif, If - help! Angel160 Excel Worksheet Functions 2 November 3rd 04 05:23 PM
countif, again Liz G Excel Worksheet Functions 2 November 1st 04 11:20 PM


All times are GMT +1. The time now is 05:41 AM.

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

About Us

"It's about Microsoft Excel"