I have used the following code and it works perfectly:
Function GetColorCount(CountRange As Range, CountColor As Range)
Dim CountColorValue As Integer
Dim TotalCount As Integer
CountColorValue = CountColor.Interior.ColorIndex
Set rCell = CountRange
For Each rCell In CountRange
If rCell.Interior.ColorIndex = CountColorValue Then
TotalCount = TotalCount + 1
End If
Next rCell
GetColorCount = TotalCount
End Function
But, now I want to do a little more. For the range of cells, I want to have 4 separate user defined functions.
1) Count cells IF they are a particular color, as well as the value inside ending in "*o"
2) Count cells IF they are a particular color, as well as the value inside ending in "*s"
3) Count cells IF they are a particular color, as well as the value in the cell having 2 text characters in the cell, "??"
4) Count cells IF they are a particular color, as well as the value in the cell being a number greater than zero, ">0".
How can I modify the base "GetColorCount" code to incorporate this additional parameter for each instance?
Function GetColorCount(CountRange As Range, CountColor As Range)
Dim CountColorValue As Integer
Dim TotalCount As Integer
CountColorValue = CountColor.Interior.ColorIndex
Set rCell = CountRange
For Each rCell In CountRange
If rCell.Interior.ColorIndex = CountColorValue Then
TotalCount = TotalCount + 1
End If
Next rCell
GetColorCount = TotalCount
End Function
But, now I want to do a little more. For the range of cells, I want to have 4 separate user defined functions.
1) Count cells IF they are a particular color, as well as the value inside ending in "*o"
2) Count cells IF they are a particular color, as well as the value inside ending in "*s"
3) Count cells IF they are a particular color, as well as the value in the cell having 2 text characters in the cell, "??"
4) Count cells IF they are a particular color, as well as the value in the cell being a number greater than zero, ">0".
How can I modify the base "GetColorCount" code to incorporate this additional parameter for each instance?