Delete Table Rows (Blank) Macro Question

F

Fred

Hi all,

I have this macro delete table rows blank which does not work on a table
after I make changes to a row such as split cell 2 columns or insert rows
using CTRL ALT I - am I missing something? Is there a macro that can delete
blank rows regardless of how they are inserted.

If you just create a blank table using Insert Table, ie drag mouse across
number of colums rows and type in some rows it is fine and deletes blank
rows. The moment you add rows or split cells on a row it gives this error:
Runtime error 5941 the requested member of the collecton does not exist
(after running). Can I refine it to acknowledge blank lines inserted using
CTRL ALT I and split cells in a blank row? Is it viable? What am I missing?

Thank you to whomever can assist.

Public Sub DelTableRowsBlank()
Dim flag As Boolean, I As Long, j As Long, atable As Table
Set atable = Selection.Tables(1)
With atable
For I = .rows.Count To 1 Step -1
flag = False
For j = 1 To .Columns.Count
If Len(.Cell(I, j).Range) > 2 Then
flag = True
Exit For
End If
Next j
If flag = False Then
.rows(I).Delete
End If
Next I
End With

End Sub
 
F

Fred

Hi,
I will add that if you TAB to insert a new row at end of table it can delete
those but puts error code for split cell rows inserted with CTR.ALT I and
through another method.

Anyone know why 2003 table markers are dependent on the insertion metthd of
the row or a fix would be great.

Many tks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top