
Originally Posted by
PcMax
I messed around a bit 'to run in a loop vba.
If you really need to do this in VBA (instead of using one of the formulas Admin or I posted earlier), then you can use this macro...
Code:
Sub CountDupesBackwards()
Dim LastRow As Long
Const DataColumn As String = "A"
Const OutputColumn As String = "B"
Const StartRow As Long = 2
LastRow = Cells(Rows.Count, DataColumn).End(xlUp).Row
With Cells(StartRow, OutputColumn).Resize(LastRow - StartRow + 1)
.Formula = "=COUNTIF(" & DataColumn & StartRow & ":" & DataColumn & _
"$" & LastRow & "," & DataColumn & StartRow & ")"
.Value = .Value
End With
End Sub
Bookmarks