Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: Thu, 15 Nov 2007 10:02:17 -0800 (PST),    group: microsoft.public.word.vba.beginners        back       


Counting Text Occurrence In A Multi-row Range   
I've been working to find a solution to counting the cells in a Word
table that are in a multirow range, and have an "X" as text. (Table is
13 rows X 32 columns)  Using the code below, I get a count of all of
the "X"s in rows 2 and 3.  What I want to do is count the "X"s in the
range (in this case, 2, 31 thru 3, 2).  Can someone please explain why
this code counts the complete rows, and give a possible solution?
TIA
Sub DoCount()
Dim tmpCount As Integer, CurrCol As Integer, CurrRow As Integer, MyStr
As String, MyRange As Range
        tmpCount = 0
        MyStr = "x"
    Set MyTable = ActiveDocument.Tables(1)
    Set MyRange = ActiveDocument.Range(Start:=MyTable.Cell(2,
31).Range.Start, _
        End:=MyTable.Cell(3, 2).Range.End)
        MyRange.Find.Execute FindText:=MyStr, Forward:=False
        While MyRange.Find.Found = True
            tmpCount = tmpCount + 1
            MyRange.Find.Execute
        Wend
MsgBox ("There are " & tmpCount & " finds")
End Sub
date: Thu, 15 Nov 2007 10:02:17 -0800 (PST)   author:   unknown

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us