jeudi 22 mars 2018

VBA If-statement with AND Operator

I am using the following code which works perfectly:

If ComboBox3.ListIndex = 0 And ComboBox4.ListIndex = 3 Then
ID1 = "GS-T10-"
Elseif ComboBox3.ListIndex = 0 And ComboBox4.ListIndex = 4 Then
ID1 = "PB-"
Elseif ComboBox3.ListIndex = 0 And ComboBox4.ListIndex = 5 Then
ID1 = "PE-"   

As you can see It is if statement with AND operator evaluating 2 conditions. However notice that my first condition is always the same (ComboBox3.ListIndex = 0), and only the second condition is changing. Is there a way to just write the first condition (which is not changing) once at the beginning of the IF Statement and hence only write the second condition after each Elseif??

Thank you,

Aucun commentaire:

Enregistrer un commentaire