A Microsoft Word forum. Microsoft Office Word Forum - WordBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Microsoft Office Word Forum - WordBanter forum » Microsoft Word Newsgroups » Microsoft Word Help
Site Map Home Authors List Search Today's Posts Mark Forums Read Web Partners

automatically remove empty rows in a table



 
 
Thread Tools Display Modes
  #1  
Old February 6th 05, 03:23 AM
Ginger
external usenet poster
 
Posts: n/a
Default automatically remove empty rows in a table

How ould I remove all empty rows within a table without having to select each
one?
Ads
  #2  
Old February 6th 05, 05:11 AM
Jezebel
external usenet poster
 
Posts: n/a
Default

Sort the table. Then all the empty rows will fall together and you can
delete them all at once.


"Ginger" wrote in message
...
How ould I remove all empty rows within a table without having to select
each
one?



  #3  
Old February 6th 05, 05:34 AM
Greg Maxey
external usenet poster
 
Posts: n/a
Default

Yes that would work.

You could stick your cursor in the table and run this macro:
Sub ScratchMacro()

Dim oTbl As Table
Dim oRow As Row
Dim oCell As Cell
Dim bNotEmpty As Boolean

Set oTbl = Selection.Tables(1)
bNotEmpty = False
For Each oRow In oTbl.Rows
For Each oCell In oRow.Cells
If Len(oCell.Range.Text) 2 Then
bNotEmpty = True
Exit For
End If
Next
If bNotEmpty = False Then oRow.Delete
bNotEmpty = False
Next

End Sub
--
Greg Maxey/Word MVP
A Peer in Peer to Peer Support

Jezebel wrote:
Sort the table. Then all the empty rows will fall together and you can
delete them all at once.


"Ginger" wrote in message
...
How ould I remove all empty rows within a table without having to
select each
one?



  #4  
Old February 6th 05, 06:31 AM
Jezebel
external usenet poster
 
Posts: n/a
Default

That's more elegant in that it doesn't muck up the order of rows. Are you
aware that it will fail if the table has vertically merged cells? (Which is,
to be sure, an unlikely circumstance in this case.)



"Greg Maxey" wrote in message
...
Yes that would work.

You could stick your cursor in the table and run this macro:
Sub ScratchMacro()

Dim oTbl As Table
Dim oRow As Row
Dim oCell As Cell
Dim bNotEmpty As Boolean

Set oTbl = Selection.Tables(1)
bNotEmpty = False
For Each oRow In oTbl.Rows
For Each oCell In oRow.Cells
If Len(oCell.Range.Text) 2 Then
bNotEmpty = True
Exit For
End If
Next
If bNotEmpty = False Then oRow.Delete
bNotEmpty = False
Next

End Sub
--
Greg Maxey/Word MVP
A Peer in Peer to Peer Support

Jezebel wrote:
Sort the table. Then all the empty rows will fall together and you can
delete them all at once.


"Ginger" wrote in message
...
How ould I remove all empty rows within a table without having to
select each
one?





  #5  
Old February 6th 05, 12:26 PM
Greg Maxey
external usenet poster
 
Posts: n/a
Default

Jezebel,

No I wasn't aware at the time. I only tested with a very simple table. It
seems that one should be able to select rows above and below merged vertical
cells and run a similiar routine but how doesn't seem to be readily
apparent. Hmmm.

--
Greg Maxey/Word MVP
A Peer in Peer to Peer Support

Jezebel wrote:
That's more elegant in that it doesn't muck up the order of rows. Are
you aware that it will fail if the table has vertically merged cells?
(Which is, to be sure, an unlikely circumstance in this case.)



"Greg Maxey" wrote in message
...
Yes that would work.

You could stick your cursor in the table and run this macro:
Sub ScratchMacro()

Dim oTbl As Table
Dim oRow As Row
Dim oCell As Cell
Dim bNotEmpty As Boolean

Set oTbl = Selection.Tables(1)
bNotEmpty = False
For Each oRow In oTbl.Rows
For Each oCell In oRow.Cells
If Len(oCell.Range.Text) 2 Then
bNotEmpty = True
Exit For
End If
Next
If bNotEmpty = False Then oRow.Delete
bNotEmpty = False
Next

End Sub
--
Greg Maxey/Word MVP
A Peer in Peer to Peer Support

Jezebel wrote:
Sort the table. Then all the empty rows will fall together and you
can delete them all at once.


"Ginger" wrote in message
...
How ould I remove all empty rows within a table without having to
select each
one?



  #6  
Old February 6th 05, 01:50 PM
Jezebel
external usenet poster
 
Posts: n/a
Default

If there are vertically merged cells, the Rows property is not valid; and
similarly, if horizontally merged then the Columns is invalid. You can test
the table's Uniform property if you need to check, or just trap the error.

This is one instance (the only one that I know of, in fact) where the
Selection object provides a function not available wsith Range objects. Even
when there are merged cells, you can still select columns and rows using the
mouse ...


"Greg Maxey" wrote in message
...
Jezebel,

No I wasn't aware at the time. I only tested with a very simple table.
It seems that one should be able to select rows above and below merged
vertical cells and run a similiar routine but how doesn't seem to be
readily apparent. Hmmm.

--
Greg Maxey/Word MVP
A Peer in Peer to Peer Support

Jezebel wrote:
That's more elegant in that it doesn't muck up the order of rows. Are
you aware that it will fail if the table has vertically merged cells?
(Which is, to be sure, an unlikely circumstance in this case.)



"Greg Maxey" wrote in message
...
Yes that would work.

You could stick your cursor in the table and run this macro:
Sub ScratchMacro()

Dim oTbl As Table
Dim oRow As Row
Dim oCell As Cell
Dim bNotEmpty As Boolean

Set oTbl = Selection.Tables(1)
bNotEmpty = False
For Each oRow In oTbl.Rows
For Each oCell In oRow.Cells
If Len(oCell.Range.Text) 2 Then
bNotEmpty = True
Exit For
End If
Next
If bNotEmpty = False Then oRow.Delete
bNotEmpty = False
Next

End Sub
--
Greg Maxey/Word MVP
A Peer in Peer to Peer Support

Jezebel wrote:
Sort the table. Then all the empty rows will fall together and you
can delete them all at once.


"Ginger" wrote in message
...
How ould I remove all empty rows within a table without having to
select each
one?





 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2002 Word Table Rows Sarah LeV Tables 3 January 28th 05 03:31 AM
Dragging table column resets Sedonakids Tables 0 January 12th 05 02:11 AM
ALT+SHIFT+Arrow shortcut to move table rows Nicola Tables 3 December 16th 04 10:58 PM
Remove Rows from a Table after merging Kevin L Mailmerge 1 December 9th 04 12:13 PM
How do I remove additional page breaks from a table? Megabite Tables 4 November 9th 04 05:12 PM


All times are GMT +1. The time now is 02:32 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
Copyright 2004-2022 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.