Show individual words from a block of text and count them

Glen Charles Rowel

New Member
Joined
Oct 11, 2004
Messages
44
Does anyone know how to write a formula that lists all the words from one cell alphabetically, and counts how many times they occur?

I want to find out which English words are used the most to help people learn English in Japan.

:help:

If you can write formulas, I just want to copy and past something.

Here is a cool formula for your help :hungry: To figure out how old you are.

By the way, I'm new at this. So, I'm just learning by copying and pasting.


1922/12/12

=DATEDIF(A4,TODAY(),"y")&" years, "&DATEDIF(A4,TODAY(),"ym")&" months & "&DATEDIF(A4,TODAY(),"md")&" days."
 
Welcome

Assume you have a text string like this in cell A1 (you will need at least one space between each word in the cell):

junk bag junk kind zebra animal

To find the number of words, use this formula:
=LEN(TRIM(A1))-LEN(SUBSTITUTE(TRIM(A1)," ",""))+1
assuming that there is a space between each word.

To list the words, use this formula in cell A4:
=IF(B4="","",MID(LEFT(TRIM($A$1),SEARCH(" ",TRIM($A$1),B3+1)-1),B3+1,100))

and this one in cell B4:
=IF(ISERROR(SEARCH(" ",TRIM($A$1),B3+1)),"",SEARCH(" ",TRIM($A$1),B3+1))

To count how may times each word appears, try this in cell C4:
=IF(A4="","",COUNTIF($A:$A,$A4))

Then copy the formulas down.

I hope that this helps

Is this what you want?
 
Upvote 0
Hi

The above will miss out the last word. Building on this

A4 has
=IF(B4="","",MID(TRIM($A$1),B3+1,B4-B3))
B4 has
=IF(ISERROR(SEARCH(" ",TRIM($A$1),B3+1)),LEN($A$1),SEARCH(" ",TRIM($A$1),B3+1))
C4 has
=IF(A4="","",COUNTIF($A:$A,$A4))

and copy down. Only problem is column B will continue to show a number.


Tony
 
Upvote 0
Re: Show individual words from a block of text and count the

:pray: Thank you very much tactps. The code is almost perfect. The only problem I had was that words that are already listed keep on popping up and the one at the end was missing.

For example:

goat frog fish mouse frog hit cat cat cat dog cat
11

goat 5 1
frog 10 2
fish 15 1
mouse 21 1
frog 26 2
hit 30 1
cat 34 3
cat 38 3
cat 42 3
dog 46 1


If you know how to stop the words popping up like cat (3 times) it would be great.





Also thank you very much Tony. Your code was also great and it fixed the last word disapearing problem, but it wasn't counted with the other "cat"s. If either of you know how to fix these problems I would be very happy.

This is what I got when I used your code Tony.


goat frog fish mouse frog hit cat cat cat dog cat


goat 5 1
frog 10 2
fish 15 1
mouse 21 1
frog 26 2
hit 30 1
cat 34 3
cat 38 3
cat 42 3
dog 46 1
cat 49 1
49
49
49
49
49
49
49
49
49

I also tried these formulas with Japanese text and as long as I used English spaces and not Japanese ones the code worked perfectly :-D

Thank you very very much :-D
 
Upvote 0
Re: Show individual words from a block of text and count the

How do I do that? Will it remove the copies from the formula?

Thanks fro the advice
 
Upvote 0
Re: Show individual words from a block of text and count the

data, text to columns.

Wont delete duplicates, but it will split out words into seperate cells so you can work with them easier.
 
Upvote 0
Re: Show individual words from a block of text and count the

That might be very useful but I'm not sure how to use it to get what I want.

What I want to do is keep all the text in the A1 cell because later I will be copying and pasting stories into A1.

Then have all the words and how many times they occur listed.

In the future I will be pasting newspapers into A1 to make a study list of words for Japanese students. This way I can check what they should be studying. :-D
 
Upvote 0

Forum statistics

Threads
1,226,798
Messages
6,193,063
Members
453,773
Latest member
bclever07

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