I have a spreadsheet template that needs to run different macros based on which check boxes are ticked before a button is pressed. I wrote this in an if statement which was fine with a couple of check boxes but gets exponentially longer as to the number of ifs you need to build in to work out all the scenarios. Right now there are 6 boxes that could be checked and this should run for all the possibilities.
Let's keep it simple and call the check boxes CB1 - CB6 and they should run corresponding macros M1 - M6 depending on which CB's are checked, in any combination (ie, you could choose to run CB1 and CB5 to run M1 and M5, or you could choose all 6 to run all 6 macros).
Right now it looks like:
Sub Checkboxes()
If ActiveSheet.CB("CB1").Value = 1_
and ActiveSheet.CB("CB2").Value = 1 Then
Call M1
Call M2
ElseIf ActiveSheet.CheckBoxes"CB1").Value = 1_
And ActiveSheet.CheckBoxes("CB2").Value = 0 Then
Call M1
ElseIf ActiveSheet.CheckBoxes("CB2").Value = 1_
And ActiveSheet.CheckBoxes("CB1").Value = 0 Then
Call M2
Else: MsgBox "Please select at least one option to proceed."
End If
End Sub
But you can see how writing an if statement for every scenario gets VERY long and surely not the best way to write it.

