How can I count the number of times a phrase is repeated in a row?

gohotels

New Member
Joined
May 10, 2012
Messages
7
Hello, does anybody know how I can count the number of times each unique phrase in row "A" is repeated?

For example if my data set was

Blue
Green
Black
Green
Red
Red
Red
Red Hat

how can I get excel to count the number of times and return data like

Blue 1
Green 2
Black 1
Green 2
Red 3
Red 3
Red 3
Red Hat 1

Any help would be appreciated!
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Try jindon's code on a copy of your workbook

Code:
Sub test()
Dim e
With CreateObject("Scripting.Dictionary")
    For Each e In Sheets(1).Range("a2").CurrentRegion.Value
        If Not IsEmpty(e) Then .Item(e) = .Item(e) + 1
    Next
    For Each e In .keys
        If .Item(e) = 1 Then .Remove e
    Next
    Sheets(2).Cells(1).Resize(.Count, 2).Value = _
    Application.Transpose(Array(.keys, .items))
    Sheets(2).Cells(1).CurrentRegion.Columns(2) _
    .NumberFormat = "0"" Times"""
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top