morales7_0
New Member
- Joined
- Jun 19, 2012
- Messages
- 6
I found this code online but didn't quite work out after a few modifications. What I'm trying to do is compare two ranges. First range contains text in the cells and the second range contains cells with background/filled color. What I'm trying to do is only count the number of cells that do not have a background/fill color in the second range and that match specific text in the first range.
For example:
Range 1 Range 2
CDQ
CDQ (Filled red)
CDI
CDI
CDI (Filled red)
CDI
WK
WK
Wk
Result should display the following on another range of cells like this:
CDQ = 1
CDI = 3
WK = 3
Any help with is greatly appreciated. Thanks!
Function ColorFunction(rColor As Range, rQual As Range)
Dim rCell As Range
Dim rCell2 As Range
Dim vResult
For Each rCell In rColor
For Each rCell2 In rQual
If rCell.Interior.ColorIndex <> xlNone And rCell2.Value = "CDQ" Then
vResult = 1 + vResult
End If
Next rCell2
Next rCell
ColorFunction = vResult
End Function
For example:
Range 1 Range 2
CDQ
CDQ (Filled red)
CDI
CDI
CDI (Filled red)
CDI
WK
WK
Wk
Result should display the following on another range of cells like this:
CDQ = 1
CDI = 3
WK = 3
Any help with is greatly appreciated. Thanks!
Function ColorFunction(rColor As Range, rQual As Range)
Dim rCell As Range
Dim rCell2 As Range
Dim vResult
For Each rCell In rColor
For Each rCell2 In rQual
If rCell.Interior.ColorIndex <> xlNone And rCell2.Value = "CDQ" Then
vResult = 1 + vResult
End If
Next rCell2
Next rCell
ColorFunction = vResult
End Function