简体   繁体   English

ComboBox 使用 Excel 2013 VBA 覆盖另一个 ComboBox

[英]ComboBox is Overriding Another ComboBox using Excel 2013 VBA

I am trying to use comboboxes to hide/unhide specific sections of my excel sheet.我正在尝试使用组合框来隐藏/取消隐藏我的 Excel 工作表的特定部分。

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).我有一个隐藏/取消隐藏特定单元格块 (ComboBox1) 的组合框和另一个隐藏/取消隐藏该块 (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.单击 ComboBox1 更新工作表后,是否可以执行 ComboBox2。

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如果你只是想调用事件,只需调用 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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