Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Greetings,
I am trying to use a select case statement where the case is every 7th number. In a For/Next loop it would be written: For i = 14 to 42 step 7 ... Next i How would you do that for Select Case? Anyone help will be appreciated. -Minitman |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dim d As Double
d = num / 7 If Int(num / 7) < d Then d = -1 Select Case d Case 2: Case 3 etc, to Case 6 Case -1: ' not a multiple of 7 Case Else: ' some other multiple of 7 End Select Regards, Peter T "Minitman" wrote in message ... Greetings, I am trying to use a select case statement where the case is every 7th number. In a For/Next loop it would be written: For i = 14 to 42 step 7 ... Next i How would you do that for Select Case? Anyone help will be appreciated. -Minitman |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub JustInCase()
Dim i As Integer i = Application.InputBox(Prompt:="Number??", Type:=1) Select Case i Case 14 MsgBox ("fourteen") Case 21 MsgBox ("twenty one") Case 28 MsgBox ("twenty eight") Case 35 MsgBox ("thirty five") Case 42 MsgBox ("fourty two") Case Else MsgBox ("something else") End Select End Sub -- Gary''s Student - gsnu200909 "Minitman" wrote: Greetings, I am trying to use a select case statement where the case is every 7th number. In a For/Next loop it would be written: For i = 14 to 42 step 7 ... Next i How would you do that for Select Case? Anyone help will be appreciated. -Minitman . |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hey Gary's Student,,
Thanks for the reply. As you can see from the reply to Peter reply, I already have a simple solution that is working. What I am trying to do is streamline my code. Sorry for the misunderstanding. -Minitman On Sun, 17 Jan 2010 04:40:01 -0800, Gary''s Student wrote: Sub JustInCase() Dim i As Integer i = Application.InputBox(Prompt:="Number??", Type:=1) Select Case i Case 14 MsgBox ("fourteen") Case 21 MsgBox ("twenty one") Case 28 MsgBox ("twenty eight") Case 35 MsgBox ("thirty five") Case 42 MsgBox ("fourty two") Case Else MsgBox ("something else") End Select End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Newbie: Problem with 'Select Case' testing syntax | Excel Programming | |||
Select Case syntax | Excel Programming | |||
Select Case for Active Worksheet syntax. | Excel Programming | |||
Syntax for Select Case | Excel Programming | |||
Select Case syntax | Excel Programming |