Search code examples
excellistboxmultipagevba

VBA Excel: Listbox Appears on All MultiPages


I have a userform with a multipage box on it. There are a few tabs on this multipage. I inserted a ListBox on the first page but it seems to appear no matter what tab is selected. I only want it to appear on the first page. Is there a property to change this?

Here is my code for opening the new multipage userform (TabData):

Unload MainSelectionForm
TabData.Show

As you can see, on the first page there is a ListBox (black border)

Clicking on the second tab, there is still a listbox


Solution

  • You should handle the change event of the MultiPage (the object that handles the tab), following logic code should work, suit to your needs (this is in the UserForm code).

    Private Sub MultiPage1_Change()
    If MultiPage1.Value = 0 Then
    ListBox1.Visible = True
    Else
    ListBox1.Visible = False
    End If
    End Sub
    

    enter image description here