SUMIF Wild Card formula for two words in cell
:
I suppose one could expand to three...?
if you have 3 A the formula takes it as correct because AAA contains AA.
Try it with a UDF:
Function mySum(myRng As Range) As Double
Dim varData As Variant
Dim i As Long
varData = myRng
For i = 1 To UBound(varData)
If InStr(varData(i, 1), "AA") And InStr(varData(i, 1), "CC") Then
mySum = mySum + varData(i, 2)
End If
Next
End Function
And call this function in the sheet with
=mySum(E1:F7)
That's good to have, the UDF, I'll for sure use that.
I was actually thinking of how to look for AA BB & CC words in a single cell where the entire contents of the cell would be something like...
AA XX CC VVV BB RRRR
and really wonder how useful that would ever be. Probably not worth pursuing, I really don't have a need at hand for that, just curious.
I tried to reference cell values using the formulas you offered, where the cells would each hold a CC and a BB etc. but it did not work. Returned 0.
Howard
|