Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Select case question
I'd like to compress the following code down to just the one Select block.
The only difference between the two is that in the second I'm testing for two conditions. There are actually five of these altogether, so the code gets quite lengthy as a result of the "DO SOME STUFF" part (which doesn't change). The range that I'm selecting doesn't change either - only the lp_cnt and the number of tests changes m1L, m2L etc). If lp_cnt = 1 Then Select Case Lsh.Cells(lk_rw, lk_cl).Value Case m1L "DO SOME STUFF" End Select End If If lp_cnt = 2 Then Select Case Lsh.Cells(lk_rw, lk_cl) Case m1L, m2L "DO SOME STUFF" End Select End If Is there a way to set the case test for a variable amount of tests i.e. (and I know this wouldn't work because I can't have a statement between Select and Case) If lp_cnt = 1 Then: Case m1L If lp_cnt = 2 Then: Case m1L, m2L If lp_cnt = 3 Then: Case m1L, m2L, m3L If lp_cnt = 4 Then: Case m1L, m2L, m3L, m4L If lp_cnt = 5 Then: Case m1L, m2L, m3L, m4L, m5L Regards, Brett |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
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 |