2 comparison operators in select case at same level without loss i
Hi,
This will give the accuracy you requi-
If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub
If Not Intersect(Target, Range("A1:A30")) Is Nothing Then
Select Case Target.Value
Case Is 0.6
SlidingCommission = 0.175
Case Is 0.5
SlidingCommission = 0.22
Case Is 0
SlidingCommission = 0.275
End Select
End If
Target.Offset(0, 1).Value = SlidingCommission
End Sub
Mike
"rd" wrote:
Hi,
I am not an expert programmer. I want to know if it is possible to use two
comparison operators in a select case statement, at the same level? I want
the code in a UDF function to test whether a certain ratio falls between 2
values, say, 30<x<=40, if it does the function returns a value ; otherwise,
it should test for next higher level 40<x<=50, etc.
Using If...Then...Else code, the UDF looks like this:
Public Function SlidingCommission(pLossRatio As Single) As Single
If pLossRatio <= 0.50 Then
SlidingCommission = 0.275 'Maximium Commission is 27.50%
ElseIf pLossRatio 0.50 And pLossRatio <= 0.6 Then
SlidingCommission = 0.22
ElseIf pLossRatio 0.6 And pLossRatio <= 0.7 Then
SlidingCommission = 0.175 .
.
.
End If
End Function
My question is: can a select case be used instead of the If...Then...Else
code without losing precsion.
You input is greatly appreciated.
RD
|