Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
change data of entire column from small case to upper case | Excel Worksheet Functions | |||
How do I change from upper case to proper case in excel 2002 | Excel Discussion (Misc queries) | |||
Changing multiple cell text from lower case to upper case | Excel Discussion (Misc queries) | |||
Change the text from lower case to upper case in an Excel work boo | Excel Discussion (Misc queries) | |||
How to use formula auditing to change upper case to Title Case. | Excel Worksheet Functions |