Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 03-30-2021, 09:08 PM
gmayor's Avatar
gmayor gmayor is offline Adding new rows to a table Windows 10 Adding new rows to a table Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,144
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

You could use a macro in the document template (or in the document if saved as macro enabled, but not the normal template or it will apply to all tables) to add two rows and format them as you tab out of the last cell.
Code:
Sub NextCell()
'Graham Mayor - https://www.gmayor.com - Last updated - 31 Mar 2021
Dim oTable As Table
Dim iCol As Integer, iRow As Integer
Dim lngLast As Long
    Set oTable = Selection.Tables(1)
    With oTable
        iCol = .Columns.Count
        iRow = .Rows.Count
        If Selection.InRange(.Cell(iRow, iCol).Range) Then
            lngLast = Val(.Cell(iRow, 1).Range.Text)
            .Rows(iRow).Range.Rows.Add
            .Rows(iRow).Range.Rows.Add
            .Rows(iRow + 1).Shading.BackgroundPatternColor = RGB(234, 244, 246)
            .Rows(iRow + 2).Shading.BackgroundPatternColor = wdColorAutomatic
            .Rows(iRow + 2).Cells(1).Range.Text = lngLast + 1
            .Rows(iRow + 2).Cells(2).Range.Select
            '.Rows(iRow + 2).Range.Style = "Form Body"
            Selection.Collapse 1
        Else
            Selection.Cells(1).Next.Range.Select
            Selection.Collapse 1
        End If
    End With
lbl_Exit:
    Set oTable = 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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Adding Rows To Table With Content Control lord_kaiser Word VBA 2 08-01-2020 01:01 AM
Adding new rows to a table Add Rows to table that will include content controls of previous rows bobsagat Word VBA 20 01-27-2020 08:00 AM
Adding new rows to a table Adding Rows to a Table SuzeG Word VBA 8 01-02-2014 08:05 AM
Adding new rows to a table Grouping table rows to prevent individual rows from breaking across pages dennist77 Word 1 10-29-2013 11:39 PM
Adding new rows to a table adding rows to word table hklein Word VBA 4 07-18-2011 12:21 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:34 AM.


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