Trying to create a simple loop that will change the visibility of a large quantity of CheckBoxes when a certain value is selected within a ComboBox . I'm very new VBA programming and loops are not something I've tried yet. My code currently is this:

Sub ComboBox1_Change()
    Dim cb As String
    Dim i As Long
    Dim x As String
    
    cb = "CheckBox"
    i = 0

    For i = 1 To 30
        If ComboBox1.Value = "Subgroup Means by Time" Then
            
            x = a & i
            x.Visible = True
        Else
            x = a & i
            x.Visible = False
        End If
    Next i
End Sub
When I run it, I get a "Compile Error: Invalid qualifier". I'm not sure what that means, but then again I'm not sure what a lot of this stuff means ha. Any ideas?

I do have a long version that works but I'm trying to learn how to make more efficient code. The original "long" code looks like this and repeats 30 times:

Sub ComboBox1_Change()
      If ComboBox1.Value = "Subgroup Means by Time" Then CheckBox1.Visible = True Else CheckBox1.Visible = False
      If ComboBox1.Value = "Subgroup Means by Time" Then CheckBox2.Visible = True Else CheckBox2.Visible = False
      ' ....28 more lines of code
End Sub
Thanks!