Find specific words on clipboard and calculate instances to a variable

Hi All,

I'd like to analyze a clipboard's text to find a specific list of words, then count the number of times those words are found and set that number to a variable. For example:

Sample clipboard contains text:
"Bill and Ted went on an excellent adventure. Bill went back in time, while Ted was transported to the future."

List of words to find:
Bill
excellent
went

Result to variable:
5

"Bill" was found twice, "excellent" once, and "went" twice, so the total number of found words was 5. I know there must be an easy way to do this, but I'm getting stuck at counting the total found words. Thanks in advance for your help!
Scott

This works for me. See if you can modify it for your needs:

Count Word Instances.kmmacros (4.4 KB)
image

Results
15%20AM

Works perfectly!! Thank you!!

1 Like