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

B

Benjamino5

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!
 
L

Lene Fredborg

Use a comma to separate the values instead of "Or":

Case "This", "That"

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top