help with case

M

Matthew Dyer

Here's what I've got:

Select Case Maxdpd
Case Is <= 39
dpdval = R15
Case Is <= 59 > 39
dpdval = R2
Case Is <= 89 > 59
dpdval = R3
Case Is > 89
dpdval = R4
End Select

As you can probably guess, this is not working. dpdval is returning 0
for every case except the <= 39. How do i fix this?
 
D

DanB

Matthew,

Case does not calculate OR type statements nor does it process multiple
cases as it falls through. Therefore, just remove the trailing ' > XX ' out
of each statement and you should find that it works.

DB
 
J

JLGWhiz

It will only execute the first case that meets the criteria.
Each case is effectively an Or statement in this particular code.

Select Case Maxdpd
Case Is <= 39 'If it is > 39 next case
dpdval = R15
Case Is <= 59 'If it is > 59 next case
dpdval = R2
Case Is <= 89 'If it is > 89 next case
dpdval = R3
Case Is > 89
dpdval = R4
End Select
 
D

Don Guillett

Sub selecttry()
Dim x As Integer
Select Case Val(InputBox("num"))
Case 1 To 5: x = 1
Case 6 To 10: x = 2
Case Else
End Select
MsgBox x
End Sub
 
D

DanB

Matthew,
Don G's answer is the most correct. I totally forgot that you can test for
ranges.

DB
 
Top