Select Case question

  • Thread starter Thread starter Brettjg
  • Start date Start date
B

Brettjg

Hi ther, I would like to compress five different Select Case statements into
1 if possible. What I have is:
If lp_cnt = 1 Then
Select Case xxxx
Case m1L
Do some stuff
End Select
End If
If lp_cnt = 2 Then
Select Case xxxx
Case m1L, m2L
Do some stuff
End Select
End If

and so on for 5 tests of lp_cnt.
Can I just set the Case test to "m1L" or "m1L, m2L" depending in the value
of lp_cnt, and therfore have only one Select Case (the "do some stuff" bit is
reasonably long you see)? Regards, Brett
 
The answer could depend on the on tests that you did not show us. can you
copy/paste your entire Select Case block? Also, I'm guessing xxxx is the
name of a variable and it is the same variable in each of your Select Case
statements, right?
 
Apologies Rick, yes xxxx is always the same.

Rick Rothstein said:
The answer could depend on the on tests that you did not show us. can you
copy/paste your entire Select Case block? Also, I'm guessing xxxx is the
name of a variable and it is the same variable in each of your Select Case
statements, right?
 
Back
Top