View Single Post
 
Old 05-22-2017, 12:48 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

It is easy enough with a macro. The following assumes the result will go in the last cell in the column containing the cursor and that there are no merged/split cells in the table.

Code:
Sub CountNums()
Dim oTable As Table
Dim lngCount As Long: lngCount = 0
Dim oCell As Cell
Dim oRng As Range
Dim i As Integer
Dim iCol As Integer
Dim iRow As Integer

Set oTable = Selection.Tables(1)
    iRow = oTable.Rows.Count
    If Selection.InRange(oTable.Range) = True Then
        iCol = Selection.Cells(1).ColumnIndex
        For i = 1 To iRow - 1
            lngCount = lngCount + Split(oTable.Columns(iCol).Cells(i).Range.Text, Chr(32))(0)
        Next i
        Set oRng = oTable.Columns(iCol).Cells(iRow).Range
        oRng.End = oRng.End - 1
        oRng.Text = lngCount
    End If
lbl_Exit:
    Set oCell = Nothing
    Set oRng = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote