merterino
merterino

Reputation: 25

Excel VBA multi-chechbox control on userform

I'm confused about checkbox controls on userforms. I have to control the values of all checkboxes in my form and take actions depending on the values.For example, If cb(checkbox) 1,2 and 3 are True then excel will do action A. If cb 2,4 and 5 are True then excel will do action B and so on...

enter image description here

How can I control multiple checkbox values without so many if statements?

Upvotes: 0

Views: 355

Answers (1)

user3598756
user3598756

Reputation: 29421

you could go with the following kind of pseudocode:

With Me
    Select Case True
        Case .CheckBox1 And .CheckBox2 And .CheckBox3
            ' action A
        Case .CheckBox2 And .CheckBox4 And .CheckBox5
            ' action B
        Case ... ' other cases
            ' corresponding action

        Case Else ' if no preceeding cases are met
            ' default action
End With

Upvotes: 3

Related Questions