![]() |
help with case
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? |
help with case
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 "Matthew Dyer" wrote: 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? |
help with case
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 "Matthew Dyer" wrote in message ... 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? |
help with case
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 -- Don Guillett Microsoft MVP Excel SalesAid Software "Matthew Dyer" wrote in message ... 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? |
help with case
Matthew,
Don G's answer is the most correct. I totally forgot that you can test for ranges. DB "Don Guillett" wrote: 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 -- Don Guillett Microsoft MVP Excel SalesAid Software "Matthew Dyer" wrote in message ... 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? |
All times are GMT +1. The time now is 09:57 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com