OK, try this:
Change the code to:
Code:
Public Function CheckRange(MyRange, MyValue) As Long
Dim wk1 As Variant, wk2 As Variant, i As Long, lb As Long, ub As Long
Dim MyData As Variant, r As Long
MyData = MyRange.Value
For r = 1 To UBound(MyData)
wk1 = Split(MyData(r, 1), "/")
For i = 0 To UBound(wk1)
wk2 = Split(wk1(i), ">")
lb = wk2(0)
ub = wk2(UBound(wk2))
If MyValue >= lb And MyValue <= ub Then
CheckRange = r + MyRange.Row - 1
Exit Function
End If
Next i
Next r
End Function
Just to provide a bit more information, I changed it so that the function returns the first row where the match was found, instead of TRUE/FALSE. Not found = 0. The nice thing about this is that Conditional Formatting considers 0=FALSE, and non-zero=TRUE.
| A | B | L | M | N | O |
---|
101>123 | | | | | | |
13/15/19/24 | | | | | | |
101>123/125/128/15>20/25 | | | | | | |
177>190/195 | | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]101[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]TRUE[/TD]
[TD="align: center"]2[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]TRUE[/TD]
[TD="align: center"]3[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]18[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]TRUE[/TD]
[TD="align: center"]4[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]17[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]TRUE[/TD]
[TD="align: center"]5[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]88[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]FALSE[/TD]
[TD="align: center"]6[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]110[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]TRUE[/TD]
[TD="align: center"]7[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]178[/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]TRUE[/TD]
[TD="align: center"]8[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]FALSE[/TD]
</tbody>
Sheet9
[TABLE="width: 85%"]
<tbody>[TR]
[TD]
Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]N1[/TH]
[TD="align: left"]=checkrange(
$A$1:$A$500,M1)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]O1[/TH]
[TD="align: left"]=IF(
checkrange($A$1:$A$500,M1),TRUE)[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
As you can see, if you put the formula in column N, you'll see the list of matching row numbers. To use it with Conditional Formatting, just select column M and use the formula in N1. (If you use the formula on the sheet and want to see TRUE/FALSE instead of a number, either use the variant formula in O1, or we can tweak the UDF a little.)
Let me know how this works!