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

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Select Case Syntax

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Select Case Syntax

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 293
Default Select Case Syntax

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
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
Newbie: Problem with 'Select Case' testing syntax Thomas Toth Excel Programming 9 September 11th 07 04:34 PM
Select Case syntax Alan Beban Excel Programming 14 July 15th 07 11:51 PM
Select Case for Active Worksheet syntax. mikeburg[_43_] Excel Programming 2 December 2nd 05 12:26 AM
Syntax for Select Case Susan Hayes Excel Programming 4 November 30th 05 10:49 AM
Select Case syntax Susan Hayes Excel Programming 2 December 4th 04 10:42 PM


All times are GMT +1. The time now is 12:18 PM.

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

About Us

"It's about Microsoft Excel"