简体   繁体   中英

ComboBox is Overriding Another ComboBox using Excel 2013 VBA

I am trying to use comboboxes to hide/unhide specific sections of my excel sheet.

I have one combobox that hides/unhides a specific block (ComboBox1) of cells and another that hides/unhides sections of cells within that block(ComboBox2).

Everything works accept when I go to unhide the whole block, it overrides the sections that Ive selected hidden within that block.

Is there a way to execute ComboBox2 after clicking ComboBox1 to update the worksheet.

Private Sub ComboBox3_Click()
    ComboBox3.TextAlign = fmTextAlignCenter
    ComboBox3.List = Array("1", "2", "3", "4")
    If ComboBox3.Value = "1" Then
        'ranges to be hidden = True/False
    End If
End Sub
Private Sub ComboBox4_Click()
    ComboBox4.TextAlign = fmTextAlignCenter
    ComboBox4.List = Array("0", "5", "6", "7", "8", "9", "10")
    If ComboBox4.Value = "0" Then
        'Ranges to be hidden in ComboBox3 block of cells'
    End if
End Sub

If you just want to call the Event, just call ComboBox4_Click

Private Sub ComboBox3_Click()
    ComboBox3.TextAlign = fmTextAlignCenter
    ComboBox3.List = Array("1", "2", "3", "4")
    If ComboBox3.Value = "1" Then
     'ranges to be hidden = True/False
    End If

    Combo4Handler

End Sub
Private Sub ComboBox4_Click()
    Combo4Handler
End Sub

Private Sub Combo4Handler()
    ComboBox4.TextAlign = fmTextAlignCenter
    ComboBox4.List = Array("0", "5", "6", "7", "8", "9", "10")
    If ComboBox4.Value = "0" Then
    'Ranges to be hidden in ComboBox3 block of cells'
    End if
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM