Select Case

M

Mike V

I am using the following select case statement:
Public Function adjgd(grade As Single)
Select Case grade
Case Is <= 0.0249
adjgd = 0
Case 0.025 To 0.0749
adjgd = 1
Case 0.075 To 0.1249
adjgd = 2
Case Is > 0.1249
adjgd = 3
Case Else
adjgd = 0
End Select
End Function

I would like to select on cases with negative values. Anyone able to help?

Thanks in advance
 
B

Bernard Liengme

What do you mean by: I would like to select on cases with negative values ?
How about: Case is < 0
best wishes
 
R

Rick Rothstein

Bernard's question is pretty much the one I have too. To go into a little
more detail... do you want to trap any and all negative values as Bernard's
"Case Is < 0" would handle or do you want to trap a series of steps in a
range as you are now doing for positive numbers. If the latter, what are the
step points and what values do you want to assign to the 'adjgd' variable
for them?
 
M

Mike V

I woant to use the same value as in the example, only negative rather than
positiion values,
i.e.,
Case Is <=-0.02499
adjgd = 0
Case Is -0.025 To -0.0749
adjgd = 1
Case IS -0.075 To -01.249
adjgd = 3
Case Else
adjgd = 0
End Select
End Function

It treates the (-) as a positive value.

Hope that helps!!
 
R

Rick Rothstein

Change your Select Case statement to this...

Select Case Abs(grade)

--
Rick (MVP - Excel)


Mike V said:
I woant to use the same value as in the example, only negative rather than
positiion values,
i.e.,
Case Is <=-0.02499
adjgd = 0
Case Is -0.025 To -0.0749
adjgd = 1
Case IS -0.075 To -01.249
adjgd = 3
Case Else
adjgd = 0
End Select
End Function

It treates the (-) as a positive value.

Hope that helps!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top