Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-09-2017, 06:11 AM
NevilleT NevilleT is offline Nested tables. Count rows Windows 7 64bit Nested tables. Count rows Office 2003
Novice
Nested tables. Count rows
 
Join Date: Mar 2015
Posts: 29
NevilleT is on a distinguished road
Default

This is the final code.

Sub subNumberTableColumns()

Dim objTable As Table
Dim intRowNo As Integer
Dim intCounter As Integer

On Error GoTo Error_subNumberTableColumns

'---------------------------------------------------------------
' Must be in a table to delete it
If funIsTable = False Then
MsgBox "You must be in a table to number the table.", vbCritical, "Number Block"
GoTo Exit_subNumberTableColumns
Else ' In a table


Set objTable = Selection.Tables(1)
intRowNo = objTable.Rows.Count ' Rows in the table

objTable.Cell(2, 1).Select ' Go to the cell below the header

'---------------------------------------------------------------
' Enter numbers in each row
For intCounter = 1 To intRowNo - 1 ' Number of rows minus the header
Selection.HomeKey Unit:=wdLine ' Start of the line
Selection.Range.Text = intCounter & ". "
Selection.MoveDown
Next intCounter
End If

Exit_subNumberTableColumns:
On Error GoTo 0
Exit Sub

Error_subNumberTableColumns:

MsgBox "An unexpected situation arose in your program." & vbCrLf & _
"Please write down the following details:" & vbCrLf & vbCrLf & _
"Module Name: " & "(MODULE_NAME)" & vbCrLf & _
"Type: VBA Document: " & vbCrLf & _
"Calling Procedure: " & "(PROCEDURE_NAME}" & vbCrLf & _
"Error Number: " & Err.Number & vbCrLf & _
"Error Descritption: " & Err.Description & vbCrLf & vbCrLf & _
"Resume Exit_" & "(PROCEDURE_NAME)" & vbCrLf & _
"Resume"

End Sub

Thanks Greg
Reply With Quote
Reply

Tags
nested table



Similar Threads
Thread Thread Starter Forum Replies Last Post
Nested tables. Count rows Getting the Count formula to count all rows Jennifer Murphy Word Tables 11 08-23-2016 09:37 PM
simple way to count rows in a table? bkcell Word 4 03-09-2015 09:06 PM
copying nested if over multiple rows where one value stays fixed charles_cat Excel 1 01-23-2015 01:30 AM
Nested tables. Count rows Count rows and add blank rows accordingly Hoochtheseal Word VBA 1 01-29-2013 09:23 PM
Nested vlookup with varable tables! Dave Jones Excel 0 08-30-2012 09:15 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:33 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft