I have to count number of distinct values from a column and print it with the distinct value and count in another sheet. I am working with this piece of code, but for some reason, it is not returning any result. Could anyone tell me where I am missing the piece!
Dim rngData As Range
Dim rngCell As Range
Dim colWords As Collection
Dim vntWord As Variant
Dim Sh As Worksheet
Dim Sh1 As Worksheet
Dim Sh2 As Worksheet
Dim Sh3 As Worksheet
On Error Resume Next
Set Sh1 = Worksheets("A")
Set Sh2 = Worksheets("B")
Set Sh3 = Worksheets("C")
Sh1.Range("A2:B650000").Delete
Set Sh = Worksheets("A")
Set r = Sh.AutoFilter.Range
r.AutoFilter Field:=24
r.AutoFilter Field:=24, Criteria1:="My Criteria"
Sh1.Range("A2:B650000").Delete
Set colWords = New Collection
Dim lRow1 As Long
lRow1 = <some number>
Set rngData = <desired range>
For Each rngCell In rngData.Cells
colWords.Add colWords.Count + 1, rngCell.Value
With Sh1.Cells(1 + colWords(rngCell.Value), 1)
.Value = rngCell.Value
.Offset(0, 1) = .Offset(0, 1) + 1
End With
Next
Above is my full code.. My required outcome is simple, count number of occurrences of each cell in a column, and print it in another sheet with the count of occurrences. Thanks!
Thanks! Navs.