简体   繁体   中英

Excel VBA Userform Controls

Good morning all,

I have a ComboBox and a MultiPage in an Excel Userform. What I would like to create is a Sub that basically sets the Visibility to 0 for all MultiPage pages where the name does not equal the ComboBox selection, but I'm getting stuck.

 Sub changeMultiPageVisibility()
 If userForm.templateComboBox = "Criteria1" Then While 
 multiPage.Names <> userForm.templateComboBox Set multiPage.Pages.Visible = 0

I'm still new to working with VBA and UserForms, if anyone can point me in the right direction I'd greatly appreciate it. Thanks!

I would use this code for ComboBox change event :

Private Sub templateComboBox_Change()
    Dim p As MSForms.Page

    For Each p In MultiPage.Pages
        p.Visible = (p.Name = templateComboBox.Value)
    Next
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