How can I count numbers of specific letter in a word document

  • Thread starter Thread starter andy222222222222
  • Start date Start date
A

andy222222222222

I have to count specific number of letters (a, t, g, and
c) for research purpose in a document. How can I do that
in word 2000?
 
Same as in any other version of Word. Search for the specific letter and
replace it with itself. When the Find and Replace operation is completed,
Word will tell you how many replacements it made. Low-tech but effective.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
Run the following macro on the document and it will create a list of all of
the characters at the end of it with the number of times that each appears:

Dim i As Long, j As Long
For i = 65 To 122
j = 0
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:=Chr(i), MatchWildcards:=False,
MatchCase:=True, Wrap:=wdFindStop, Forward:=True) = True
j = j + 1
Selection.Collapse wdCollapseEnd
Loop
End With
ActiveDocument.Range.InsertAfter Chr(i) & vbTab & j & vbCr
Next i


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
Back
Top