Finding most common words in excel

Joshyd

New Member
Joined
Mar 6, 2019
Messages
17
Hi there,

I have several survey question responses. Many of them are paragraphs in single cells. I am wondering if there is a way for excel to look at every word (not just the cell as a whole) and return the most common words.

The problem I am running into is that I want to look at each word, which may be many in a single cell as opposed to the whole cell value. This is because essentially all the cells are unique values. I am not yet sure how many top words I would need (depends on the results). If any suggestions included an easy way to modify the number of words returned, that would be awesome.

Many thanks in advance.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Which cells contain your paragraphs?
 
Upvote 0
Ok, how about this
Code:
Sub Joshyd()
    Dim Ary As Variant, Sp As Variant, Elmt As Variant
    Dim r As Long, c As Long
    
    Ary = Sheets("[COLOR=#ff0000]Sheet1[/COLOR]").Range("D2:BY60").Value2
    With CreateObject("scripting.dictionary")
        For c = 1 To UBound(Ary, 2)
            For r = 1 To UBound(Ary)
                For Each Elmt In Split(Ary(r, c))
                    .Item(Elmt) = .Item(Elmt) + 1
                Next Elmt
            Next r
            If .Count > 0 Then Sheets("[COLOR=#ff0000]Sheet2[/COLOR]").Cells(2, c * 2 - 1).Resize(.Count, 2).Value = Application.Transpose(Array(.Keys, .Items))
            .RemoveAll
        Next c
    End With
End Sub
Change sheet names to suit.
The 2nd sheet (sheet2 in the code) is where it will output the results
 
Upvote 0
Try this, The result on the same sheet in the columns CA y CBCheck the result and you can order the number of words from highest to lowest.

Code:
Sub Finding_most_common_words()
  Dim c As Range, w As Variant, dict As Object
  Set dict = CreateObject("scripting.dictionary")
  For Each c In Range("D2:BY60")
    For Each w In Split(c, " ")
      dict(w) = Val(dict(w)) + 1
    Next
  Next
  Range("CA2").Resize(dict.Count) = Application.Transpose(dict.Keys)
  Range("CB2").Resize(dict.Count) = Application.Transpose(dict.Items)
End Sub
 
Upvote 0
Glad you were able to sort it & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,242
Members
452,623
Latest member
russelllowellpercy

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