
Originally Posted by
MarvinP
If a built-in function or formula is available, why not use it as they are ALWAYS faster than VBA or Array formulas.
Not always.
try
Sub CountItems()
Dim a, i As Long, n As Long
a = Sheets("jan").Cells(1).CurrentRegion.Value
With CreateObject("Scripting.Dictionary")
a(1, 2) = "Count": n = 1
For i = 2 To UBound(a, 1)
If (a(i, 2) = "TBA") + (a(i, 2) = "8IM") Then
If Not .exists(a(i, 1)) Then
n = n + 1: .Item(a(i, 1)) = n
a(n, 1) = a(i, 1): a(n, 2) = 1
Else
a(.Item(a(i, 1)), 2) = a(.Item(a(i, 1)), 2) + 1
End If
End If
Next
End With
Sheets("list").Cells(1).Resize(n, 2).Value = a
End Sub
Bookmarks