Here's a VBA sub that runs in a reasonable time
Sub countPrior()
Dim dic As Object
Dim i As Long
Dim dat As Variant
Dim dat2 As Variant
' Get source data range, copy to variant array
dat = Cells(1, 2).Resize(Cells(Rows.Count, 1).End(xlUp).Row, 1)
' create array to hold results
ReDim dat2(1 To UBound(dat, 1), 1 To 1)
' use Dictionary to hold count values
Set dic = CreateObject("scripting.dictionary")
' loop variant array
For i = 1 To UBound(dat, 1)
If dic.Exists(dat(i, 1)) Then
' return count
dat2(i, 1) = dic.Item(dat(i, 1))
' if value already in array, increment count
dic.Item(dat(i, 1)) = dic.Item(dat(i, 1)) + 1
Else
' return count
dat2(i, 1) = 0
' if value not already in array, initialise count
dic.Add dat(i, 1), 1
End If
Next
' write result to sheet
Cells(1, 3).Resize(Cells(Rows.Count, 1).End(xlUp).Row, 1) = dat2
End Sub