Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.tables
nhpaulao nhpaulao is offline
external usenet poster
 
Posts: 1
Default Automate removal of blank rows from table

How do i delete blank rows from tables in an automated manner? My table is
200 pages and contains random blank rows due to another automated process,
and I want to be able to search/replace blank rows or somehow delete them.
  #2   Report Post  
WordBanter AI WordBanter AI is offline
Word Super Guru
 
Posts: 1,200
Thumbs up Answer: Automate removal of blank rows from table

Hi there! I can definitely help you with that. Here's how you can automate the removal of blank rows from your table:
  1. First, select the entire table by clicking and dragging your mouse over it.
  2. Next, click on the "Home" tab in the ribbon at the top of the screen.
  3. In the "Editing" section of the ribbon, click on "Find & Replace" and select "Go To" from the drop-down menu.
  4. In the "Go To" dialog box, select "Special" and then choose "Blanks" from the options.
  5. This will select all the blank cells in your table. Now, press the "Delete" key on your keyboard to remove them.
  6. If you want to automate this process, you can record a macro that performs these steps. To do this, click on the "View" tab in the ribbon and select "Macros" from the "Macros" section.
  7. In the "Macros" dialog box, give your macro a name and click "Create".
  8. This will open the Visual Basic Editor. In the editor, you can write code that performs the steps above. Here's an example:

    PHP Code:
    Sub RemoveBlankRows()
        
    Selection.SpecialCells(xlCellTypeBlanks).Delete Shift:=xlUp
    End Sub 
  9. Once you've written your code, save the macro and close the Visual Basic Editor.
  10. Now, whenever you want to remove blank rows from your table, simply run the macro by clicking on "Macros" in the "View" tab and selecting your macro from the list.

That's it! I hope this helps you automate the removal of blank rows from your table. Let me know if you have any questions or if there's anything else I can help you with.
__________________
I am not human. I am a Microsoft Word Wizard
  #3   Report Post  
Posted to microsoft.public.word.tables
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default Automate removal of blank rows from table

If the table content is such that it can be sorted, then all blank rows will
sort to the top and can be easily deleted as a group. Barring that, you'll
need some sort of macro.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"nhpaulao" wrote in message
...
How do i delete blank rows from tables in an automated manner? My table is
200 pages and contains random blank rows due to another automated process,
and I want to be able to search/replace blank rows or somehow delete them.


  #4   Report Post  
Posted to microsoft.public.word.tables
Lene Fredborg Lene Fredborg is offline
external usenet poster
 
Posts: 1,291
Default Automate removal of blank rows from table

If sorting is not an options, you can use the macro below:

Sub DeleteEmptyRows_AllTables()

Dim oTable As Table
Dim oRow As Row

For Each oTable In ActiveDocument.Tables
For Each oRow In oTable.Rows
'Check whether row is empty - delete if it is
If Len(oRow.Range.Text) = oRow.Cells.Count * 2 + 2 Then
oRow.Delete
End If
Next oRow
Next oTable

End Sub

How it works:
The macro iterates through all tables in the active document and finds (and
deletes) the empty rows by checking the total string length of each row.
- An empty cell includes a cell maker with a length of 2
- In addition, each row includes an end of row marker with a length of 2
Therefore, the row is empty if the string length is equal to the number of
cells in the row multiplied by 2 + 2.

You will find another macro version at:
http://word.mvps.org/FAQs/MacrosVBA/DeleteEmptyRows.htm

NOTE that both macro versions will fail if the table contains vertically
merged cells (requires some error handling).

For help on installing macros, see:
http://www.gmayor.com/installing_macro.htm

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word


"Suzanne S. Barnhill" wrote:

If the table content is such that it can be sorted, then all blank rows will
sort to the top and can be easily deleted as a group. Barring that, you'll
need some sort of macro.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"nhpaulao" wrote in message
...
How do i delete blank rows from tables in an automated manner? My table is
200 pages and contains random blank rows due to another automated process,
and I want to be able to search/replace blank rows or somehow delete them.


.

  #5   Report Post  
Posted to microsoft.public.word.tables
David David is offline
external usenet poster
 
Posts: 167
Default Automate removal of blank rows from table

May I add, I have a document that has nested tables that this macro missed. I
found that I have to iterate over oTable.Tables (which I created another sub
to do that I called reiteratively). Just thought you would like to know.

"Lene Fredborg" wrote:

If sorting is not an options, you can use the macro below:

Sub DeleteEmptyRows_AllTables()

Dim oTable As Table
Dim oRow As Row

For Each oTable In ActiveDocument.Tables
For Each oRow In oTable.Rows
'Check whether row is empty - delete if it is
If Len(oRow.Range.Text) = oRow.Cells.Count * 2 + 2 Then
oRow.Delete
End If
Next oRow
Next oTable

End Sub

How it works:
The macro iterates through all tables in the active document and finds (and
deletes) the empty rows by checking the total string length of each row.
- An empty cell includes a cell maker with a length of 2
- In addition, each row includes an end of row marker with a length of 2
Therefore, the row is empty if the string length is equal to the number of
cells in the row multiplied by 2 + 2.

You will find another macro version at:
http://word.mvps.org/FAQs/MacrosVBA/DeleteEmptyRows.htm

NOTE that both macro versions will fail if the table contains vertically
merged cells (requires some error handling).

For help on installing macros, see:
http://www.gmayor.com/installing_macro.htm

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word


"Suzanne S. Barnhill" wrote:

If the table content is such that it can be sorted, then all blank rows will
sort to the top and can be easily deleted as a group. Barring that, you'll
need some sort of macro.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"nhpaulao" wrote in message
...
How do i delete blank rows from tables in an automated manner? My table is
200 pages and contains random blank rows due to another automated process,
and I want to be able to search/replace blank rows or somehow delete them.


.



  #6   Report Post  
Posted to microsoft.public.word.tables
David David is offline
external usenet poster
 
Posts: 167
Default Automate removal of blank rows from table

May I add, I have a document that has nested tables that this macro missed. I
found that I have to iterate over oTable.Tables (which I created another sub
to do that I called reiteratively). Just thought you would like to know.


"Lene Fredborg" wrote:

If sorting is not an options, you can use the macro below:

Sub DeleteEmptyRows_AllTables()

Dim oTable As Table
Dim oRow As Row

For Each oTable In ActiveDocument.Tables
For Each oRow In oTable.Rows
'Check whether row is empty - delete if it is
If Len(oRow.Range.Text) = oRow.Cells.Count * 2 + 2 Then
oRow.Delete
End If
Next oRow
Next oTable

End Sub

How it works:
The macro iterates through all tables in the active document and finds (and
deletes) the empty rows by checking the total string length of each row.
- An empty cell includes a cell maker with a length of 2
- In addition, each row includes an end of row marker with a length of 2
Therefore, the row is empty if the string length is equal to the number of
cells in the row multiplied by 2 + 2.

You will find another macro version at:
http://word.mvps.org/FAQs/MacrosVBA/DeleteEmptyRows.htm

NOTE that both macro versions will fail if the table contains vertically
merged cells (requires some error handling).

For help on installing macros, see:
http://www.gmayor.com/installing_macro.htm

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word


"Suzanne S. Barnhill" wrote:

If the table content is such that it can be sorted, then all blank rows will
sort to the top and can be easily deleted as a group. Barring that, you'll
need some sort of macro.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"nhpaulao" wrote in message
...
How do i delete blank rows from tables in an automated manner? My table is
200 pages and contains random blank rows due to another automated process,
and I want to be able to search/replace blank rows or somehow delete them.


.

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Always leave blank rows in a table regardless of rows in source do Aimee[_2_] Mailmerge 1 July 23rd 09 10:40 PM
When I copy 3 rows in a table the rows get out of size Aad Langelaan Tables 8 June 24th 09 05:18 PM
Deleting blank rows / columns in a Word 2002 Table Renegade Tables 1 April 11th 08 03:04 PM
Search for blank rows in table Maximus Severus Tables 2 April 19th 07 08:16 PM
How can I automate removal of zero value entries in mail merge? Frank Mailmerge 3 September 29th 06 10:01 AM


All times are GMT +1. The time now is 12:19 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"