A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Tables
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

count how often a letter appears within text



 
 
Thread Tools Display Modes
  #1  
Old December 21st, 2005, 10:47 AM posted to microsoft.public.word.tables
external usenet poster
 
Posts: n/a
Default count how often a letter appears within text

ROAR for R is equal to 2 . OAR for R is equal to 1. ORR for R is equal to 2.
The totals are R = 5, O = 3 and A = 2 appearances. What formulae can I use
to count how many times a letter appears in a text?

----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.

http://www.microsoft.com/office/comm...ic.word.tables
  #2  
Old December 21st, 2005, 11:30 AM posted to microsoft.public.word.tables
external usenet poster
 
Posts: n/a
Default count how often a letter appears within text

At the most basic level, select the text and use Find/Replace to replace the
character with itself. Word will tell you how many occurrences were
replaced.

Cheers


"astrologer" wrote in message
...
ROAR for R is equal to 2 . OAR for R is equal to 1. ORR for R is equal to

2.
The totals are R = 5, O = 3 and A = 2 appearances. What formulae can I

use
to count how many times a letter appears in a text?



  #3  
Old March 26th, 2006, 11:52 PM posted to microsoft.public.word.tables
external usenet poster
 
Posts: n/a
Default count how often a letter appears within text

"macropod" wrote:
At the most basic level, select the text and use Find/Replace to replace
the character with itself. Word will tell you how many occurrences were
replaced.



If you want to get more sophisticated, you'd need a macro. The one below
should do the trick, and append a table with the results at the end of the
document.

If you need help with macros, see
http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm

Regards,
Klaus


Sub CodesFast()
Dim myString, myStringNew, myChar, myCode
Dim strOutput, HexString, myCharCount
myString = ActiveDocument.Content.Text
strOutput = ""
Do
myChar = left$(myString, 1)
myStringNew = Replace(myString, myChar, "", 1, _
Compa=vbBinaryCompare)
myCharCount = Len(myString) - Len(myStringNew)
myCode = AscW(myChar) And &HFFFF&
strOutput = strOutput & (myCode) & vbTab
StatusBar = myCode
HexString = Hex$(myCode)
While Len(HexString) 4
HexString = "0" & HexString
Wend
strOutput = strOutput & "U+" & HexString & vbTab
If myCode 31 Then
strOutput = strOutput & myChar
End If
strOutput = strOutput & vbTab & LTrim(str$(myCharCount))
strOutput = strOutput & vbCr
myString = myStringNew
Loop Until Len(myString) = 0
ActiveDocument.Content.Select
Selection.Collapse Direction:=wdCollapseEnd
Selection.Range.InsertParagraphBefore
Selection.TypeText Text:=" "
Selection.Expand Unit:=wdParagraph
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="Codes"
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
Selection.Collapse Direction:=wdCollapseStart
Selection.TypeText strOutput
Selection.GoTo What:=wdGoToBookmark, Name:="Codes"
Selection.ConvertToTable Separator:=wdSeparateByTabs
Selection.Sort ExcludeHeader:=False, FieldNumber:=1, _
SortFieldType:=wdSortFieldNumeric, _
SortOrder:=wdSortOrderAscending
Selection.Rows.ConvertToText Separator:=wdSeparateByTabs
ActiveDocument.Bookmarks("Codes").Delete
End Sub


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is Access even the right idea? BMB New Users 19 November 21st, 2005 08:01 PM
Add New Field to DB Karen Database Design 7 October 19th, 2005 08:03 PM
Combo Box (1st) Populating Text Box (2nd) Field AccessRookie Using Forms 1 April 6th, 2005 11:37 PM
Help with design Ronnie Database Design 6 March 12th, 2005 02:53 PM
find a date on sheet 2 and count text in that column jtinne General Discussion 4 October 4th, 2004 09:06 PM


All times are GMT +1. The time now is 03:23 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.