title: Excel VBA Form Control - Reset Listbox Scroll Bar
body: <p>I have written the below code to pull the data from six listboxes (multiselect) on the same sheet, pass the selections to a module for calculation and then clear the listbox selections. The only issue which seems negligible although very frustrating is getting the listbox 'scroll bar' for each listbox to reset its position to the top of the list.</p>
  
  <p>I have tried .TopIndex but because i am using a form control and not an ActiveX control it returns "object" not supported. </p>
  
  <p>Does anyone know how to reset the listbox scroll bar position to the top of the form control listbox?</p>
  
  <pre><code>Sub Listboxproperties_click()
  
      'store selected items from listbox into an array
      Dim listarray()
      Dim J As Integer
      Dim R As Integer
      Dim i As Integer
  
      'Add selected items into the array
      ReDim listarray(1 To 50, 1 To 6)
      'Counter
      J = 0
      For R = 1 To 6
          Set lb = ActiveSheet.ListBoxes("ListBox" &amp; R)
          For i = 1 To lb.ListCount
              If lb.Selected(i) = True Then
                  'add 1 to the counter
                  J = J + 1
                  'Store selection in an array
                  listarray(J, R) = lb.list(i)
              End If
          Next i
          J = 0
      Next R
  
      'Check if msgbox has a selection if not exit sub
      For R = 1 To 6
          'if there is nothing in the first item of the listarray then the user has not chosen an option
          If listarray(1, R) = "" Then
              MsgBox "You have not selected a option, please select and retry"
              Exit Sub
          End If
      Next R
  
      'input box for the name of the Trend
  
      Linename = InputBox("Please enter a name for the call type you are calculating i.e. Adviser Calls, Withdrawal   Status etc", "Call Trend")
  
      If Linename = "" Then
          MsgBox "No name selected, please retry and enter a name for your call flow"
          Exit Sub
      End If
  
      Call UniqueCount(listarray, Linename)
  
      'clear selections from listbox
      For R = 1 To 6
          Set lb = ActiveSheet.ListBoxes("ListBox" &amp; R)
          For i = 1 To lb.ListCount - 1
              If lb.Selected(i) = True Then
                  lb.Selected = False
              End If
          Next i
          lb.TopIndex
      Next R
  
  End Sub    
  </code></pre>