any ideas?
Slightly more efficient plus it will handle a passed column as well:
Function ValuesTooClose(rng As Range, lMinValue As Long) As Boolean
Dim i As Long
Dim n As Long
Dim UB As Long
Dim arr
arr = rng
UB = UBound(arr, 2)
If UB = 1 Then
'1 column wide range was passed
UB = UBound(arr)
For i = 1 To UB
For n = i + 1 To UB
If Abs(arr(i, 1) - arr(n, 1)) < lMinValue Then
ValuesTooClose = True
Exit Function
End If
Next n
Next i
Else
'1 row high range was passed
For i = 1 To UB
For n = i + 1 To UB
If Abs(arr(1, i) - arr(1, n)) < lMinValue Then
ValuesTooClose = True
Exit Function
End If
Next n
Next i
End If
End Function
RBS
"RB Smissaert" wrote in message
...
There might be an Excel worksheet function, but this UDF will do it:
Function ValuesTooClose(rng As Range, lMinValue As Long) As Boolean
Dim i As Long
Dim n As Long
Dim UB As Long
Dim arr
arr = rng
UB = UBound(arr, 2)
For i = 1 To UB
For n = i To UB
If Abs(arr(1, i) - arr(1, n)) < lMinValue And i < n Then
ValuesTooClose = True
Exit Function
End If
Next n
Next i
End Function
Then do in the sheet: Insert, Function, User Defined etc.
RBS
"rosysnozzy" wrote in message
...
Hello clever Excel people,
I have tried various different formulas with no success. Basically I have
a
row of values, lets say: 10,45,12,28,30. I need formula that I can enter
into
conditional formatting so that if any of the values are less than 3 away
from
any of the other values (eg: 10 and 12 are too close, as are 28 and 30),
it
will turn a different colour to highlight the error. Please help, I have
exhausted all the Excel geeks at work including the IT department.
Thank you :-)
|