View Single Post
  #6   Report Post  
Posted to microsoft.public.word.tables
PaulM
 
Posts: n/a
Default how do i count unique items in word table?

Many Thanks. This does the job!

"Doug Robbins - Word MVP" wrote:

The following will sum the occurences of the A's, B's, C's and D's in the
second column of the first table in the document, starting from the second
row (assuming that there is a heading in the first row)

Dim A As Long, B As Long, C As Long, D As Long, i As Long
Dim arange As Range
A = 0
B = 0
C = 0
D = 0
With ActiveDocument.Tables(1).Columns(2)
For i = 2 To .Cells.Count
Set arange = .Cells(i).Range
arange.End = arange.End - 1
Select Case arange
Case "A"
A = A + 1
Case "B"
B = B + 1
Case "C"
C = C + 1
Case "D"
D = D + 1
End Select
Next i
End With
MsgBox "There are " & A & " A's; " & B & " B's; " & C & " C's and " & D & "
D's."


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"PaulM" wrote in message
...
Excel certainly has the functionality to sum and count better than word,
however the test reports need to be in a word format (legacy reasons).
Another option is to store the info in Access and export to Word (Not an
easy
process for temp testers).

I'm not positive about 'cannot'; theres always a way, it just depends on
how
messy the way is!

"Cooz" wrote:

Dear Paul,

You cannot do this in Word. I suggest you replace the table by an Excel
table - it is a piece of cake in Excel. The Standard toolbar has a button
(with a table and the Excel icon) that allows you to do so.

Succes,
Cooz
--
PS: If this is a satisfying answer to your question and you're logged in
via
the Microsoft site, please click Yes to "Did this post answer the
question?".
Thanks.

"PaulM" wrote:

I have a software test report template, in word, that includes the
severity
of the issue in a column on a table (values being A,B,C or D). Ideally
I
would need a count of the A's and B's found within this table.