S
simplysewing
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
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