I try to use the "instring" function to make a triple filter for a counter. The main idea is to define a range and then check every cell as follows:
1) Locate content "0111" in cell
2) If content "0111" in cell found, check on the column left of this cell, if content "127" exists
3) Check if the row of the current cell is not red (color 3)
4) If all the above is true, raise counter.
My code looks as follows:
Set SrchRng4 = Range("J1:J100")
For Each cel In SrchRng4
If InStr(1, cel.Value, "0111", 1) > 0 Then
If InStr(1, ActiveCell(Offset(-1,0), "127", 1) > 0 And cel.EntireRow.Interior.ColorIndex <> 3 Then
count_K = count_K + 1
End If
Next cel
It work for the search of "111" and the exeption of the red rows but it doesn't work after the addition of the "127" filter. Can anyone provide some input on that ? I suppose it some problem with the syntax ?
Kind regards, Marcus
If InStr(1, cel.Offset(-1,0), "127", 1) > 0 And ...cel.Offset(-1,0)must becel.Offset(0,-1). Furthermore, should you have time performance issues, you may want to filter on first two conditions and then loop through filtered cells only to check the last one