Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-05-2013, 02:15 PM
Jennifer Murphy's Avatar
Jennifer Murphy Jennifer Murphy is offline Question about Case statement Windows XP Question about Case statement Office 2007
Competent Performer
Question about Case statement
 
Join Date: Aug 2011
Location: Silicon Valley
Posts: 234
Jennifer Murphy is on a distinguished road
Default Question about Case statement

Can I have a Case statement that can test for multiple values at one branch?



In the code below, I'd like the third Case statement to execute if MyString contains any of the characters "BFSTV".
Code:
Select Case UCase(MyString)
  Case ""
    MsgBox "Macro aborted", , MyName
  Case "A"
    Call SubA
  Case "BFSTV" ???   'What can go here???
    Call SubMisc
  Case "G"
    Call SubG
  Case Else
    MsgBox "Invalid data:
End Select
That is, I'd like to run this test:
Code:
If instr(1,MyString,"BFSTV")>0
Reply With Quote
  #2  
Old 01-05-2013, 02:30 PM
Jennifer Murphy's Avatar
Jennifer Murphy Jennifer Murphy is offline Question about Case statement Windows XP Question about Case statement Office 2007
Competent Performer
Question about Case statement
 
Join Date: Aug 2011
Location: Silicon Valley
Posts: 234
Jennifer Murphy is on a distinguished road
Default

I found the answer. Just code a list.
Code:
Select Case UCase(MyString)
   Case ""
     MsgBox "Macro aborted", , MyName
   Case "A"
     Call SubA
   Case "B", "F", "S", "T", "V"
     Call SubMisc
   Case "G"
     Call SubG
   Case Else
     MsgBox "Invalid data"
End Select
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Question about Case statement Regular expressions: lower case after hyphen SusanG Word 2 06-06-2012 11:58 PM
Question about Case statement Custom Text Filter for this particular case tinfanide Excel 2 09-13-2011 05:08 AM
Case Sensitive (contains) Selection apolloman Excel 2 07-12-2011 04:50 AM
Question about Case statement From all UPPER CASE to Proper Case davers Word 1 04-30-2009 12:41 PM
Upper to lower case jd Excel 1 04-28-2006 07:40 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:20 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft