ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Select Case (https://www.excelbanter.com/excel-programming/417351-select-case.html)

Mike V

Select Case
 
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







--
M.R. Vanatta

Bernard Liengme

Select Case
 
What do you mean by: I would like to select on cases with negative values ?
How about: Case is < 0
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Mike V" wrote in message
...
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

. Anyone able to help?

Thanks in advance







--
M.R. Vanatta




Rick Rothstein

Select Case
 
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?

--
Rick (MVP - Excel)


"Bernard Liengme" wrote in message
...
What do you mean by: I would like to select on cases with negative values
?
How about: Case is < 0
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Mike V" wrote in message
...
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

. Anyone able to help?

Thanks in advance







--
M.R. Vanatta





Mike V

Select Case
 
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!!
--
M.R. Vanatta


"Rick Rothstein" wrote:

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?

--
Rick (MVP - Excel)


"Bernard Liengme" wrote in message
...
What do you mean by: I would like to select on cases with negative values
?
How about: Case is < 0
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Mike V" wrote in message
...
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

. Anyone able to help?

Thanks in advance







--
M.R. Vanatta






Rick Rothstein

Select Case
 
Change your Select Case statement to this...

Select Case Abs(grade)

--
Rick (MVP - Excel)


"Mike V" wrote in message
...
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!!
--
M.R. Vanatta


"Rick Rothstein" wrote:

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?

--
Rick (MVP - Excel)


"Bernard Liengme" wrote in message
...
What do you mean by: I would like to select on cases with negative
values
?
How about: Case is < 0
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Mike V" wrote in message
...
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

. Anyone able to help?

Thanks in advance







--
M.R. Vanatta







All times are GMT +1. The time now is 09:32 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com