Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.tables
Ron Ron is offline
external usenet poster
 
Posts: 99
Default Counting non-blank cells in a column

Does anyone have a formula for counting the number of cells in a column that
contain text?

We are trying to count the number of names that appear in a column.
  #2   Report Post  
Posted to microsoft.public.word.tables
Lene Fredborg Lene Fredborg is offline
external usenet poster
 
Posts: 1,291
Default Counting non-blank cells in a column

You can use a macro. The following macro will count all non-blank cells in
the (first) column in the selection. A message displays the result.

You do not need to select the entire column before running the macro. It
will check all cells even if you have only an insertion point or if part of
the column selected.

Note that the macro will consider a cell as non-blank even if the cell
contains spaces only. Additional code can be added to prevent this if desired.

Sub CountNonBlankCellsInColumn()

Dim oCell As Cell
Dim n As Long 'used as counter

n = 0
'Check whether selection is in table
If Selection.Information(wdWithInTable) = False Then
MsgBox "The selection must be in a table. Please retry.", vbOKOnly
Exit Sub
End If
€˜Check all cells in the first column in the selection
For Each oCell In Selection.Columns(1).Cells
'Check whether row is empty - delete if it is
If Len(oCell.Range.Text) 2 Then
'Cell is not empty - count
n = n + 1
End If
Next oCell

'Show message
MsgBox "The (first) column in the selection contains " & n & _
" non-blank cells."
End Sub

For help on installing macros, see:
http://www.gmayor.com/installing_macro.htm

--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word


"Ron" wrote:

Does anyone have a formula for counting the number of cells in a column that
contain text?

We are trying to count the number of names that appear in a column.

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need formula for counting non-blank cells in a column Ron Tables 0 December 18th 07 09:45 PM
merging blank cells from excel to word i want them to stay blank n stlof Mailmerge 1 September 28th 06 06:08 PM
Selecting a column: some rows have 2 cells in 1 column? DonD Tables 4 June 15th 06 03:29 AM
Numbering cells in a column [email protected] Tables 2 October 19th 05 11:03 PM
Count non-blank cells in a table column Bradley C. Hammerstrom New Users 4 December 14th 04 02:47 AM


All times are GMT +1. The time now is 07:26 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"