Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 178
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
change data of entire column from small case to upper case Ann Excel Worksheet Functions 1 August 16th 08 01:06 PM
How do I change from upper case to proper case in excel 2002 CT Man[_2_] Excel Discussion (Misc queries) 8 January 8th 08 06:14 PM
Changing multiple cell text from lower case to upper case Patti Excel Discussion (Misc queries) 2 January 4th 08 08:35 PM
Change the text from lower case to upper case in an Excel work boo dave01968 Excel Discussion (Misc queries) 2 December 9th 05 09:09 AM
How to use formula auditing to change upper case to Title Case. ScoobeyDoo Excel Worksheet Functions 1 November 19th 04 06:26 PM


All times are GMT +1. The time now is 03:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"