I'm not that smart.
This is part of what needs changed (plus some category stuff later in the code):
you need to count contacts
lngCount = Application.Session.Categories.Count
lngCount = MyContacts.items.Count
(lngCount = MyItem.Count might work too)
' Resize array with determined size
arrCategories is just the variable for the array, no need ot change it, except to avoid confusion.
ReDim arrCategories(lngCount)
ReDim arrSorted(lngCount)
' Start populating array with categories
this needs changed,
For Each Category In Application.Session.Categories
to
For Each MyItem In MyContacts
arrCategories(i) = Category