permutation - VBA display selection options -
i trying write code display value depending on checkbox selected. there total of 5 checkboxes , adding additional checkboxes in future wondering if there easy way determine checkboxes checked determine values display. can in round way minimize code if possible.
in other words, if write each scenario out have write separate code of different selection possbilities:
1 only,2 only,3 only,4 only,5 only
1+2, 1+3, 1+4, 1+5, 2+3, 2+4, 2+5, 3+4, 3+5, 4+5
1+2+3, 1+2+4,1+2+5, 1+3+4,1+3+5, 1+4+5,2+3+4, 2+3+5,3+4+5
1+2+3+4, 1+2+3+5, 1+3+4+5, 2+3+4+5
1+2+3+4+5
each value associated sub fill array if selected. , after arrays filled need perform additional function on ones selected. function performed same not want perform function if value not selected because defeat purpose of function otherwise. function select duplicates arrays selected array.
you can use binary numbers each checkbox:
- first value 1 (
=2
0
) - second value 2 (
=2
1
) - third value 4 (
=2
2
) - fourth value 8 (
=2
2
) - fifth value 16 (
=2
4
)
hence, when sum each permutation, have unique number can check.
- 1
0
, 21
, on - 1+2
3
, 1+35
, 1+49
, 1+517
- and on
you can create arrays every case want check.
@ least, hope give ideas or tips.
regards,
Comments
Post a Comment