ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   select case multiple conditions (https://www.excelbanter.com/excel-programming/412746-select-case-multiple-conditions.html)

Chris G

select case multiple conditions
 
Is is possible to use a select case arrangement with more than one
conditional variable because if I nest it using another select case or an if
statement the code gets much longer and is not so easy to follow.

eg I tried something like this but couldn't get it to work
select case var_a, var_b
case var_a=x, var_b10
case var_a=y, var_b10
case var_a=x, var_b<11
etc
end case

Any alternative suggestions welcome

Thanks


T Lavedas

select case multiple conditions
 
On Jun 18, 7:54 am, Chris G wrote:
Is is possible to use a select case arrangement with more than one
conditional variable because if I nest it using another select case or an if
statement the code gets much longer and is not so easy to follow.

eg I tried something like this but couldn't get it to work
select case var_a, var_b
case var_a=x, var_b10
case var_a=y, var_b10
case var_a=x, var_b<11
etc
end case

Any alternative suggestions welcome

Thanks


select case true
case var_a=x and var_b10
case var_a=y and var_b10
case var_a=x and var_b<11
etc
end case

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/

Chris G

select case multiple conditions
 
I like it - very clever Tom. Thanks

"T Lavedas" wrote:

On Jun 18, 7:54 am, Chris G wrote:
Is is possible to use a select case arrangement with more than one
conditional variable because if I nest it using another select case or an if
statement the code gets much longer and is not so easy to follow.

eg I tried something like this but couldn't get it to work
select case var_a, var_b
case var_a=x, var_b10
case var_a=y, var_b10
case var_a=x, var_b<11
etc
end case

Any alternative suggestions welcome

Thanks


select case true
case var_a=x and var_b10
case var_a=y and var_b10
case var_a=x and var_b<11
etc
end case

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/



All times are GMT +1. The time now is 12:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com