
Option Explicit
Sub abc()
Dim a, i, d
a = [a1].CurrentRegion.Offset(1).Resize(, 3).Value
Set d = CreateObject("scripting.dictionary")
For i = 1 To UBound(a) - 1
d(a(i, 1)) = d(a(i, 1)) + 1
a(i, 1) = d(a(i, 1))
If a(i, 3) <> a(i + 1, 3) Then d.RemoveAll
Next
[b2].Resize(UBound(a) - 1) = a
End Sub