How to check whether the given number is between X and Y
Posted on January 4, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | 'Math - How to check whether the given number is between X and Y Function InBetween(ByVal Num As Variant, ByVal X As Variant, ByVal Y As Variant) As Boolean Dim bResult As Boolean bResult = False If IsNumeric(Num) And IsNumeric(X) And IsNumeric(Y) Then If X < Y Then If Num > X And Num < Y Then bResult = True End If ElseIf Y < X Then If Num > Y And Num < X Then bResult = True End If End If End If InBetween = bResult End Function |