+ Post New Thread
Results 1 to 7 of 7
Office Software Thread, Blank Rows in Tables in Technical; Good evening! I have a 200+ page document with a table on each page and blank rows in each table ...
  1. #1

    Join Date
    Mar 2012
    Posts
    46
    Thank Post
    17
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Blank Rows in Tables

    Good evening! I have a 200+ page document with a table on each page and blank rows in each table (following a dodgy Excel mailmerge). Is there a non-manual way of removing the rows from the tables en masse please?

    Thanks for reading !

  2. #2
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,999
    Thank Post
    120
    Thanked 280 Times in 258 Posts
    Rep Power
    106
    I have some macros I wrote to do various jobs on rows of tables. I'm sure they could be altered for you requirements. I will have a look tomorrow if nobody else posts anything.

  3. Thanks to ChrisH from:

    CarpeDiem (2nd March 2012)

  4. #3
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,999
    Thank Post
    120
    Thanked 280 Times in 258 Posts
    Rep Power
    106
    Sorry I forgot about this try something like

    Code:
    Sub CleanUpTables()
        Dim oTbl As Table
        Dim r As Row
        Dim RowContents As String
         
        For Each oTbl In ActiveDocument.Tables
            For Each oRow In oTbl.Rows
                    If CellText(oRow.Cells(1).Range.Text) = "" And CellText(oRow.Cells(2).Range.Text) = ""  Then
                        oRow.Delete
                    End If
            Next
        Next
    End Sub
    That should go through every table and if 2 cells are empty it will delete the row. You can adjust the if statement to suit your needs.

  5. Thanks to ChrisH from:

    CarpeDiem (5th March 2012)

  6. #4

    Join Date
    Mar 2012
    Posts
    46
    Thank Post
    17
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Quote Originally Posted by ChrisH View Post
    Sorry I forgot about this try something like

    Code:
    Sub CleanUpTables()
        Dim oTbl As Table
        Dim r As Row
        Dim RowContents As String
         
        For Each oTbl In ActiveDocument.Tables
            For Each oRow In oTbl.Rows
                    If CellText(oRow.Cells(1).Range.Text) = "" And CellText(oRow.Cells(2).Range.Text) = ""  Then
                        oRow.Delete
                    End If
            Next
        Next
    End Sub
    That should go through every table and if 2 cells are empty it will delete the row. You can adjust the if statement to suit your needs.

    Hi Chris

    Super - thanks. I've added this to a new macro and V-B says Compile error : Sub or Function not defined.?

  7. #5
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,999
    Thank Post
    120
    Thanked 280 Times in 258 Posts
    Rep Power
    106
    You need to loose the last and first line if you are making a new macro and putting it in.

  8. #6
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,999
    Thank Post
    120
    Thanked 280 Times in 258 Posts
    Rep Power
    106
    Sorry I just noticed the procedure you were on about, I will dig it out tomorrow.

  9. #7
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,999
    Thank Post
    120
    Thanked 280 Times in 258 Posts
    Rep Power
    106
    Code:
    Function CellText(strIn As String) As String
        CellText = Left(strIn, Len(strIn) - 2)
    End Function
    
    Sub CleanUpTables()
        Dim oTbl As Table
        Dim r As Row
        Dim RowContents As String
         
        For Each oTbl In ActiveDocument.Tables
            For Each oRow In oTbl.Rows
                    If CellText(oRow.Cells(1).Range.Text) = "" And CellText(oRow.Cells(2).Range.Text) = ""  Then
                        oRow.Delete
                    End If
            Next
        Next
    End Sub
    Here is the missing code.This is it in full now.

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 3
    Last Post: 24th March 2011, 10:02 PM
  2. access 2007 header in tables
    By imiddleton25 in forum Office Software
    Replies: 0
    Last Post: 18th May 2010, 03:54 PM
  3. How to check for blank values in SIMS marksheets
    By MattMitchell in forum MIS Systems
    Replies: 5
    Last Post: 22nd March 2010, 01:24 PM
  4. Microsoft Access Fill All Blanks in Table
    By RabbieBurns in forum Office Software
    Replies: 17
    Last Post: 18th March 2010, 12:03 PM
  5. How to get blank new window in Internet Explorer?
    By NetworkGeezer in forum Windows
    Replies: 7
    Last Post: 4th May 2007, 01:55 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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