I'm trying to iterate through a row of numbers (Col A). Many of the numbers are duplicates, and I'm going to put how many times each number appears in Column F in a row corresponding to the original number. However, I keep getting a Application Defined Error before my End If code.
Sub Iterate()
Range("A65536").End(xlUp).Select
Dim iVal As Long
Dim duplicate As Long
duplicate = Cells(2, 1).Value
For i = 3 To Range("A" & Rows.Count).End(xlUp).Row
If ActiveCell(i, 1).Value <> duplicate Then
iVal = Application.WorksheetFunction.CountIf(Range("A1:A"), ActiveCell(i, 1).Value)
duplicate = iVal
End If
iVal = duplicate
Cells(i, 6).Value = iVal
Next
End Sub
Any help would be much appreciated.