Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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? -- Rick (MVP - Excel) "Brettjg" wrote in message ... 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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Apologies Rick, yes xxxx is always the same.
"Rick Rothstein" wrote: 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? -- Rick (MVP - Excel) "Brettjg" wrote in message ... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
select case question | Excel Programming | |||
Select Case question | Excel Programming | |||
select case question | Excel Programming | |||
VBA select case question | Excel Discussion (Misc queries) | |||
Select Case Question | Excel Programming |