Akuini

VBA Macro to create Word & Phrase Frequency



W:love::love:W!!!!!! (y)(y):):)

First of all, please accept my apologies for the delayed response as I was working on something else and did not get a chance to come here and check your AMAZING WOKING CODE.

This is working PERFECT!!!!

FLAWLESS. You are an AMAZING person with magical working code.

Thank you once again for all your hard work and resolving this. Really appreciate it!!!!!!
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
This is an amazing macro that I used to run without any issues. However, today I received the following message: Run time error "70": Permission Denied. It stops here
Set regEx = CreateObject("VBScript.RegExp"); I have a reference for MS Script Regex 5.5. Does somebody have an idea what happens? Thanks!
 
Actually, I was wrong about the reference, i.e. the code actually doesn’t need reference to "Microsoft VBScript Regular Expressions 5.5" because it uses late binding method. So it should work with or without the reference to that.
As for Run time error "70": Permission Denied:
1. Can you try this sub and see where it stops?

VBA Code:
Sub just_try()
Dim d As Object, q As Object

    Set d = CreateObject("scripting.dictionary")
            Set q = CreateObject("VBScript.RegExp")

End Sub

2. Any chances you're using Malwarebytes software? There's a report that somehow Malwarebytes disabled RegExp.
 
This is an amazing macro that I used to run without any issues. However, today I received the following message: Run time error "70": Permission Denied. It stops here
Set regEx = CreateObject("VBScript.RegExp"); I have a reference for MS Script Regex 5.5. Does somebody have an idea what happens? Thanks!
I forgot to quote your question in post #24.
 
Hi and THANK YOU for posting this amazing macro. It is so helpful in what I do.
I'm not super familiar with Regex and would love know how easy it would be to add the capability to ignore any word that was only 1 or 2 characters long as well as ignoring a specific list of certain words (maybe on a second tab of the workbook that I could continually update) like "are, was, she, her, his, can, has, had, any, all, out, for, the, and, can, you" etc. ?

Thanks!
-J!m
 
ignoring a specific list of certain words (maybe on a second tab of the workbook that I could continually update) like "are, was, she, her, his, can, has, had, any, all, out, for, the, and, can, you" etc. ?
What you're looking for is called stop words. I've written the code for this, please check post 4-8.

to add the capability to ignore any word that was only 1 or 2 characters long
I'll try to amend the code to do that when I have time. I'm kind of busy right now.
 
What you're looking for is called stop words. I've written the code for this, please check post 4-8.
Thanks, found the updated code... Stop Words works GREAT! Exactly what I needed to upgrade this from Amazing to Spectacular...

For now I can add a few 1 and 2 letter common words to the Stop Word list and that will work great!

Thanks again for such an Amazing Macro.
 
I'll try to amend the code to do that when I have time. I'm kind of busy right now.
I think I figured it out. I took your stopWord code and modified it to remove 1 and 2 letter words as well as a bunch of super common words I don't care about. I call this routine right before your stopWords is called and it's working great. I'll still be using stopWords also so the user can add in some of their own words they don't want.

VBA Code:
Sub commonWord(tx As String)
    
    Const commonWords As String = ".,..,the,and,you,was,for,are,his,one,had,but,not,all,can,use,she,how,out,her,him,has,two,see,way,who,oil,its,now,day,did,get,may,that,with,they,this,have,from,word,what,were,when,your,said,each,will,many,then,them,some,make,like,into,time,look,more,than,been,call,find,long,down,come,made,part,there,which,their,other,about,these,would,write,could,first,water,number,people"
    'Define list of common Stop words to Ignore
    '. and .. will remove all 1 and 2 character words and numbers

    Dim regEx  As Object
    Dim w As String
    Dim c, i
    
    Set regEx = CreateObject("VBScript.RegExp")
    With regEx
        .Global = True
        .MultiLine = True
        .IgnoreCase = True
    End With
    
    c = Split(commonWords, ",")
    tx = " " & tx
    For i = LBound(c) To UBound(c)
        regEx.Pattern = "[^A-Z]" & c(i) & "[^A-Z]"
        If regEx.Test(tx) Then
            tx = regEx.Replace(tx, "|")           'replace stop word with "|"
        End If
    Next
    
End Sub
 
This code has been really useful. However, is there a way to limit it from running into the next cell in the column when counting occurences of phrases? I have a list of free text entries (60k rows), and wish to identify the most frequent 3-word and 4-word groups. At the moment, the return is skewed as the analysis includes the cell below. For example, the following cells would return the phrase "replacement required replacement".

faulty replacement required
replacement item ordered
Loan item sent to customer

I appreciate this thread is old, but it is a really useful piece of code and your assistance would be greatly appreciated.
 

Forum statistics

Threads
1,226,453
Messages
6,191,135
Members
453,642
Latest member
jefals

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