Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Case Statement

I don't like GoTo's:

Option Explicit
Sub testme01()

Dim Drk As Long

Drk = 0
Do
Select Case Range("A1").Value
Case Is = "Jim", "Bill"
Drk = 1
Case Is = "Jill", "Fred"
Drk = 2
Case Else
Range("A1") = InputBox("this is not a valid name, " _
& "please enter a valid name and press enter.")
End Select
If Drk = 0 Then
'keep looking
Else
Exit Do
End If
Loop

MsgBox Drk

End Sub


And you don't give the user a way to cancel out of the loop???

And if case doesn't matter:

Select Case lcase(Range("A1").Value)
Case Is = lcase("Jim"), lcase("Bill")
Drk = 1
Case Is = lcase("Jill"), lcase("Fred")



jlclyde wrote:

Is there anyway to set up this code to use OR for a case statement or
a way to check multiple things without putting in another case is =?
the code below is a general idea of what I am trying to do.

Thanks,
Jay

E:
Select Case Range("A1") .value
Case is = "Jim" or "Bill"
Drk = 1
Case is = "Jill" or "Fred"
Drk = 2
case else
range("A`1")=Inputbox("this is not a valid name, please enter a valid
name and press enter.")
goto E
End Select


--

Dave Peterson
 
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
Select Case Statement Katie Excel Worksheet Functions 13 December 1st 08 07:32 PM
import external data sql case statement burkecrosby Excel Discussion (Misc queries) 0 January 25th 07 04:26 PM
IF STATMENT OR CASE STATEMENT Richard Excel Discussion (Misc queries) 2 January 10th 07 10:04 AM
Anyone actually get Case statement to work ... ? ForestFeeder Excel Worksheet Functions 3 April 21st 06 04:14 PM
CASE statement equivalent Beema Excel Worksheet Functions 1 December 15th 04 09:32 AM


All times are GMT +1. The time now is 04:18 AM.

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"