Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Sub count_occurences()
Dim wds As Variant, occs As Variant, i As Integer
wds = Array("Can", "you", "dig", "this")
occs = Array(0, 0, 0, 0)
For i = 0 To UBound(wds)
Selection.HomeKey unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = wds(i)
.Replacement.Text = wds(i)
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Do
Selection.Find.Execute Replace:=wdReplaceOne
Selection.MoveRight unit:=wdCharacter, Count:=1
If Selection.Find.Found Then occs(i) = CInt(occs(i) + 1)
Loop Until Not Selection.Find.Found
Next i
End Sub
sub count_match()
counter = 0
For Each wd In ActiveDocument.Words
If wd = "Your word" Then
counter = counter + 1
End If
Next
MsgBox counter
end sub