Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2007

Tip: Looking for answers? Try searching our database.

How to use Select Case when several cases result in the same code?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Benjamino5 - 03 Mar 2007 22:25 GMT
I have a Select Case structure with six cases (six different values for the
variable I'm checking).

However, in three of the cases, I want to run the exact same lines of code.

How can I do this without copying and pasting the same chunk of code three
times over? If I write:

Case "This" Or "That"

VBA gives an error.

Is there another structure I should be using? A lot of If/Then statements
would be more cluttered than a Select Case, but maybe there's something else
I can use instead?

Thanks!
Lene Fredborg - 03 Mar 2007 22:32 GMT
Use a comma to separate the values instead of "Or":

Case "This", "That"

Signature

Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word

> I have a Select Case structure with six cases (six different values for the
> variable I'm checking).
[quoted text clipped - 13 lines]
>
> Thanks!
Benjamino5 - 03 Mar 2007 22:55 GMT
Oh! Thanks a lot!
Benjamino5 - 03 Mar 2007 22:56 GMT
Oh! Thanks a lot.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.