View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
rd rd is offline
external usenet poster
 
Posts: 6
Default 2 comparison operators in select case at same level without loss in precision

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 .