Consulting

Results 1 to 6 of 6

Thread: Insert rows in a table uptill the page bottom

  1. #1
    VBAX Regular
    Joined
    Nov 2022
    Posts
    7
    Location

    Insert rows in a table uptill the page bottom

    Is there a way to write vba code to insert rows in a table up to the bottom of the current page. Thank you

  2. #2
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,053
    Location
    Quote Originally Posted by kattai View Post
    Is there a way to write vba code to insert rows in a table up to the bottom of the current page.
    By ".... up to the bottom of the current page" are you referring to the last used row of the sheet
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  3. #3
    VBAX Regular
    Joined
    Nov 2022
    Posts
    7
    Location
    Quote Originally Posted by Aussiebear View Post
    By ".... up to the bottom of the current page" are you referring to the last used row of the sheet
    Yes

  4. #4
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,335
    Location
    Sub ScratchMacro()
    'A basic Word macro coded by Greg Maxey
    Dim oTbl As Table
    Dim oRng As Range
      Set oTbl = Selection.Tables(1)
      Set oRng = oTbl.Range
      oRng.Collapse wdCollapseEnd
      oRng.Move wdParagraph, 1
      Do
        oTbl.Rows.Add
      Loop While oTbl.Rows.Last.Range.Information(wdActiveEndAdjustedPageNumber) = oRng.Information(wdActiveEndAdjustedPageNumber)
    lbl_Exit:
      Exit Sub
    End Sub
    Greg

    Visit my website: http://gregmaxey.com

  5. #5
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,053
    Location
    My apologies kattai, your initial post was correct.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  6. #6
    VBAX Regular
    Joined
    Nov 2022
    Posts
    7
    Location
    Quote Originally Posted by gmaxey View Post
    Sub ScratchMacro()
    'A basic Word macro coded by Greg Maxey
    Dim oTbl As Table
    Dim oRng As Range
      Set oTbl = Selection.Tables(1)
      Set oRng = oTbl.Range
      oRng.Collapse wdCollapseEnd
      oRng.Move wdParagraph, 1
      Do
        oTbl.Rows.Add
      Loop While oTbl.Rows.Last.Range.Information(wdActiveEndAdjustedPageNumber) = oRng.Information(wdActiveEndAdjustedPageNumber)
    lbl_Exit:
      Exit Sub
    End Sub

    Thank you Greg. It works. I appreciate your timely support.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •