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
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