title: Reset listbox selection in VBA
body: <p>I'm trying to 'reset' a listbox in Excel VBA when a form closes. Currently when I use the userform1.hide function the form disappears but when I open it up again using the .show function it still has the previous selections in it. As someone who is relatively new to this can anyone help?</p>
  
  <p>The code for the listboxes is as follows:</p>
  
  <pre><code>Sub CommandButton1_Click()
  
  'Filter by Country
  Dim item As Long, dict As Object
  Dim wsData As Worksheet
  
  Set wsData = Sheets("TPID")
  Set dict = CreateObject("Scripting.Dictionary")
  
  With ListBox1
      For item = 0 To .ListCount - 1
          If .Selected(item) Then dict(.List(item)) = Empty
      Next item
  End With
  
  With wsData.ListObjects("Table_ExternalData_1").Range
      .AutoFilter Field:=1
      If dict.Count Then _
          .AutoFilter Field:=1, criteria1:=dict.keys, Operator:=xlFilterValues
  End With
  'Filter by Continent
  Dim item1 As Long, dict1 As Object
  Dim wsData1 As Worksheet
  
  Set wsData1 = Sheets("TPID")
  Set dict1 = CreateObject("Scripting.Dictionary")
  
  With ListBox2
      For item1 = 0 To .ListCount - 1
          If .Selected(item1) Then dict1(.List(item1)) = Empty
      Next item1
  End With
  
  With wsData1.ListObjects("Table_ExternalData_1").Range
      .AutoFilter Field:=4
      If dict1.Count Then _
          .AutoFilter Field:=4, criteria1:=dict1.keys, Operator:=xlFilterValues
  End With
  
  
  End Sub
  </code></pre>
  
  <p>Thanks in advance everyone,</p>