Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Select Case Range

How do you use Select Case if you have a range of numbers like 0<e<1

Not 0<=e<=1 that would be Case 0 to 1.

Here is an example:
Select Case e
Case 0
'for case 0
Case 0<e<1 'this does not work
'for case 0<e<1
Case 1
'for case 1
Case Is <1
'for all cases above 1
end select
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Select Case Range

Maybe

Select Case True
Case e = 0
'for case 0
Case 0 < e And e < 1
'for case 0<e<1
Case e = 1
'for case 1
Case e < 1
'for all cases above 1
End Select




--
__________________________________
HTH

Bob

"Philosophaie" wrote in message
...
How do you use Select Case if you have a range of numbers like 0<e<1

Not 0<=e<=1 that would be Case 0 to 1.

Here is an example:
Select Case e
Case 0
'for case 0
Case 0<e<1 'this does not work
'for case 0<e<1
Case 1
'for case 1
Case Is <1
'for all cases above 1
end select



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Select Case Range

The case statement arre execute in order and stops when a match is found.
You can use the IS format

Select Case e
Case 0
'for case 0
Case 1
'for case 1
Case is < 1
'for case 0<e<1

"Philosophaie" wrote:

How do you use Select Case if you have a range of numbers like 0<e<1

Not 0<=e<=1 that would be Case 0 to 1.

Here is an example:
Select Case e
Case 0
'for case 0
Case 0<e<1 'this does not work
'for case 0<e<1
Case 1
'for case 1
Case Is <1
'for all cases above 1
end select

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 947
Default Select Case Range

Case 0<e<1 'this does not work

Hi. The advantage of Select Case is to avoid additional calculations
inside (ie 0 < e < 1). Here's one way...

Sub Demo()
Dim n
n = 0.00001
Select Case n
Case 0
Debug.Print "0"
Case 1
Debug.Print "1"
Case 0 To 1
Debug.Print "0-1"
Case Else
Debug.Print "Outside Range"
End Select
End Sub

= = = = =
HTH
Dana DeLouis



Philosophaie wrote:
How do you use Select Case if you have a range of numbers like 0<e<1

Not 0<=e<=1 that would be Case 0 to 1.

Here is an example:
Select Case e
Case 0
'for case 0
Case 0<e<1 'this does not work
'for case 0<e<1
Case 1
'for case 1
Case Is <1
'for all cases above 1
end select

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Select Case Range

I need a "Case" that will activate when there are values such as 0.1, 0.4,
and 0.7 and not 0 or 1. How do I find that "Case"?

"Joel" wrote:

The case statement arre execute in order and stops when a match is found.
You can use the IS format

Select Case e
Case 0
'for case 0
Case 1
'for case 1
Case is < 1
'for case 0<e<1




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 947
Default Select Case Range

Just another idea.

Sub Demo()
Dim n
n = 0.00001
Select Case n
Case Is <= 0: 'Do nothing
Case Is = 1: 'Do nothing
Case 0 To 1
Debug.Print "between 0 & 1"
End Select
End Sub

= = = = =
HTH
Dana DeLouis


Dana DeLouis wrote:
Case 0<e<1 'this does not work


Hi. The advantage of Select Case is to avoid additional calculations
inside (ie 0 < e < 1). Here's one way...

Sub Demo()
Dim n
n = 0.00001
Select Case n
Case 0
Debug.Print "0"
Case 1
Debug.Print "1"
Case 0 To 1
Debug.Print "0-1"
Case Else
Debug.Print "Outside Range"
End Select
End Sub

= = = = =
HTH
Dana DeLouis



Philosophaie wrote:
How do you use Select Case if you have a range of numbers like 0<e<1
Not 0<=e<=1 that would be Case 0 to 1.

Here is an example:
Select Case e
Case 0
'for case 0
Case 0<e<1 'this does not work
'for case 0<e<1
Case 1
'for case 1
Case Is <1
'for all cases above 1
end select

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
How do I write a select case statement for range ChipButtyMan Excel Programming 5 October 13th 08 10:06 PM
Case without Select Case error problem Ayo Excel Discussion (Misc queries) 2 May 16th 08 03:48 PM
Select Case on a range - problem cdb Excel Programming 4 February 11th 05 01:37 PM
case select and a range JT[_2_] Excel Programming 2 January 27th 05 10:46 PM


All times are GMT +1. The time now is 07:26 PM.

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"