excel_noob_77
New Member
- Joined
- Jun 26, 2017
- Messages
- 6
Hey guys,
I am trying to sort a column by the occurance (or count) of a particular word. So for example if I had a column similar to this
Cat
Cat
Cat
Dog
Dog
Dog
Dog
It would sort the column based on their count (the items with the most occurance would be listed first and so forth). So it would be
Dog
Dog
Dog
Dog
Cat
Cat
Cat
Already happened to find a partial code which does a count similar to the code shown below. How should i modify this VBA code to then sort the column by frequency/count of a particular word. Could someone help me out with this.
I am trying to sort a column by the occurance (or count) of a particular word. So for example if I had a column similar to this
Cat
Cat
Cat
Dog
Dog
Dog
Dog
It would sort the column based on their count (the items with the most occurance would be listed first and so forth). So it would be
Dog
Dog
Dog
Dog
Cat
Cat
Cat
Already happened to find a partial code which does a count similar to the code shown below. How should i modify this VBA code to then sort the column by frequency/count of a particular word. Could someone help me out with this.
Code:
Sub SortMessageByCount()
Dim Mode_Client As String
Range("A" & Rows.Count).FormulaArray = _
"=INDEX(A2:A26,MODE(MATCH(A2:A26,A2:A26,0)))"
Mode_Client = Range("A" & Rows.Count)
Range("A" & Rows.Count).ClearContents
MsgBox "The message occuring the most is " & Mode_Client
End Sub