Private Sub UserForm_Initialize()
Dim frstRow As Long, lstRow As Long, cnt As Long, i As Long, j As Long
Dim objTable As ListObject
Dim rng As Range
cnt = 0
Do While (ActiveCell.Offset(cnt, 0).Value = ActiveCell.Offset(cnt - 1, 0).Value)
cnt = cnt - 1
Loop
frstRow = ActiveCell.Row + cnt
cnt = 0
Do While (ActiveCell.Offset(cnt, 0).Value = ActiveCell.Offset(cnt + 1, 0).Value)
cnt = cnt + 1
Loop
lstRow = ActiveCell.Row + cnt
Set rng = Application.Range("Complaints!A" & frstRow & ":K" & lstRow)
With rng
.Sort Key1:=.Range("Complaints!D" & frstRow & ":D" & lstRow), Order1:=xlAscending _
, Key2:=.Range("Complaints!E" & frstRow & ":E" & lstRow), Order1:=xlAscending _
, Key3:=.Range("Complaints!F" & frstRow & ":F" & lstRow), Order1:=xlAscending, Header:=xlGuess
End With
Set rng = Application.Range("Complaints!A" & frstRow & ":K" & lstRow)
i = 0
i = lstRow - frstRow
' this for loop selects columns to load to listbox
For j = 0 To i
ListBox1.AddItem rng.Cells(j + 1, 4)
ListBox1.List(j, 1) = rng.Cells(j + 1, 5)
ListBox1.List(j, 2) = rng.Cells(j + 1, 6)
ListBox1.List(j, 3) = rng.Cells(j + 1, 9)
ListBox1.List(j, 4) = rng.Cells(j + 1, 11)
Next j
' Below is for moving the whole range into the listbox
' UserForm8.ListBox1.RowSource = rng.Address
ListBox1.ListIndex = -1
Me.StartUpPosition = 0
Me.Top = 50
Me.Left = 250
End Sub