neilholmes
05-27-2011, 06:40 AM
Hi everyone, I am new to the forum and new to writing code for vba.
I am hoping that you will be able to help me.
I have been looking for a code that deletes blank rows from a table within a word document.
I have found the following code which works really well :
Dim i As Long
With Selection.Tables(1)
For i = .Rows.Count To 1 Step -1
If Len(.Cell(i, 2).Range.Text) = 2 Then
.Rows(i).Delete
End If
Next i
End With
The problem is, the code will delete all the blank cells. What I would really like the code to do is only delete the rows which are blank that follow the last row of text.
(Hope that makes sense)
For Example :
https://files.me.com/holmes.n/4vwy5j
At the moment the work around I have been using is to put a space in those 'blank' rows that I do not wish to delete.
If anyone can help that would be great.
Thanks
- Neil
I am hoping that you will be able to help me.
I have been looking for a code that deletes blank rows from a table within a word document.
I have found the following code which works really well :
Dim i As Long
With Selection.Tables(1)
For i = .Rows.Count To 1 Step -1
If Len(.Cell(i, 2).Range.Text) = 2 Then
.Rows(i).Delete
End If
Next i
End With
The problem is, the code will delete all the blank cells. What I would really like the code to do is only delete the rows which are blank that follow the last row of text.
(Hope that makes sense)
For Example :
https://files.me.com/holmes.n/4vwy5j
At the moment the work around I have been using is to put a space in those 'blank' rows that I do not wish to delete.
If anyone can help that would be great.
Thanks
- Neil