# Count words in column (with cells having more than 1 word)

#### goble

##### New Member
Hi,

I have a column (data) with words separated by comas. I would like to count how many times the words appear.

I have seen a similar post in this forum where you define the words and then you get the word count. Here I need to get both the list of the words (Column B) and their occurrence (Column C).

Thanks !

 Data Result 1 Result 2 (Count) boy,girl,man,woman aunt 3 uncle,aunt,father boy 2 aunt,man,boy father 2 woman,father,aunt girl 1 man 2 uncle 1 woman 2

### Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

#### Joe4

Assuming your column A data is in cells A2:A5, and "aunt" is in B2, put this formula in cell C2:
Excel Formula:
``=SUMPRODUCT(--(ISNUMBER(SEARCH(\$B2,\$A\$2:\$A\$5))))``
and copy down.

#### goble

##### New Member
Hi and thanks @Joe4

However I don't have the list in Column C. I need excel to find the (specific) words and then count them.

#### Rick Rothstein

##### MrExcel MVP
Assuming your data is in Column A starting at Row 2 (where Row 1 is assumed to be the headers you show), then this macro will produce the two result lists shown in Columns B and C...
VBA Code:
``````Sub GetWordsAndCount()
Dim N As Long, X As Long, Words As Variant, Arr As Variant
Arr = Range("A2", Cells(Rows.Count, "A").End(xlUp))
With CreateObject("Scripting.Dictionary")
For X = 1 To UBound(Arr)
Words = Split(Arr(X, 1), ",")
For N = 0 To UBound(Words)
.Item(Words(N)) = .Item(Words(N)) + 1
Next
Next
Range("B2").Resize(.Count) = Application.Transpose(.Keys)
Range("C2").Resize(.Count) = Application.Transpose(.Items)
Range("B2:C2").Resize(.Count).Sort Range("B2")
End With
End Sub``````
HOW TO INSTALL MACROs
------------------------------------
If you are new to macros, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. To use the macro, go back to the worksheet with your data on it and press ALT+F8, select the macro name (GetWordsAndCount) from the list that appears and click the Run button. The macro will execute and perform the action(s) you asked for. If you will need to do this again in this same workbook, and if you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.

#### goble

##### New Member
Thank you !

I'm incredibly amazed by the level of support you provide ! Again thank you so much !

Replies
1
Views
158
Replies
6
Views
611
Replies
22
Views
220
Replies
5
Views
88
Replies
4
Views
638

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

1,152,117
Messages
5,768,213
Members
425,459
Latest member
Danniey

### 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.

### Which adblocker are you using?

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

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