Word's 'Above', 'Below', 'Right' and 'Left' field expressions are quirky at
the best of times - see 'Referencing Adjacent Cells In A Row Or Column' in
the Word document at: www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=365442
(url all one line)
Having said that, you can't reliably avoid counting empty/blank cells with
{=Count(Below)}. A possible workaround, if you're counting cells with '1' in
them (or another non-zero numeric constant), might be to use something based
on {=Sum(Below)}.
I don't know how you could do this with a field. I played with a macro
today that if you put your cursor in the a blank cell in the column then it
will count a inert the number of "non-empty" fields.
Sub Test()
Dim i As Long, j As Long
Dim iCount As Long
Dim oCell As Cell
Dim oCol As Column
If Selection.Information(wdWithInTable) = True Then
i = Selection.Cells(1).RowIndex
j = Selection.Cells(1).ColumnIndex
End If
For Each oCell In Selection.Tables(1).Columns(j).Cells
If oCell.Range.Characters.Count > 1 Then
iCount = iCount + 1
End If
Next
ActiveDocument.Tables(1).Cell(i, j).Range.InsertBefore "Count = " & iCount &
" "
I believe you will want to use the code "COUNTA". It is specifaclly designed
to counta only non-blank cells. Also, if you want to only count cells that
contain numbers, i.e. don't count a heading, use "DCOUNT". Hope htis helps.
It might if the application was Excel, but this is a Word table ...
Cheers
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.