4

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!

1 Answer 1

4

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
Sign up to request clarification or add additional context in comments.

1 Comment

This worked perfectly! Time for me to go learn about For/Next statements. Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.