Countif problem by Excel VBA
Posted on 2014-07-24
Hello! I tried to do a countif function by VBA in Excel, by excel it should be like = countif("A:A",A2) .... like this and map the count to Column Z.
However my code below return all zero value......where am I get wrong? pls help....thanks.
Dim sffCount As Long
LastRow = Range("A" & Rows.Count).End(xlUp).Row
For Idx = 2 To LastRow
sffCount = Application.WorksheetFunction.CountIf(Range("A" & Rows.Count), Cells(Idx, "A").Value)
Cells(Idx, "Z") = sffCount