Excel VBA custom form controls

Good morning,

I have a ComboBox and MultiPage in a custom Excel form. What I would like to create is a Sub, which basically sets the visibility to 0 for all MultiPage pages, where the name doesn't match the ComboBox choice, but I'm 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 someone could point me in the right direction, I would really appreciate it. Thank!

+4
source share
1 answer

I would use this code for the 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
+4
source

Source: https://habr.com/ru/post/1538115/


All Articles