Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
DELETING BLANK ROWS
Can one of you experts kindly devise a macro for me so as to have from all
the tables from the text copied to a word document from a web page, blank rows deleted. There are different tables at different locations/pages. Thanx in advance. -- Best Regards, Faraz |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
DELETING BLANK ROWS
The following should work. Rows with merged cells will be ignored.
Sub DeleteBlankRows() Dim oRow As Range Dim iCount As Integer With ActiveDocument For i = .Tables.Count To 1 Step -1 For j = .Tables(i).Rows.Count To 1 Step -1 Set oRow = .Tables(i).Rows(j).Range iCount = (oRow.Columns.Count * 2) + 2 If Len(oRow) = iCount Then .Tables(i).Rows(j).Delete End If Next j Next i End With End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Faraz A. Qureshi wrote: Can one of you experts kindly devise a macro for me so as to have from all the tables from the text copied to a word document from a web page, blank rows deleted. There are different tables at different locations/pages. Thanx in advance. |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
DELETING BLANK ROWS
WOW!
A Mayor 4 sure! Thanx -- Best Regards, Faraz "Graham Mayor" wrote: The following should work. Rows with merged cells will be ignored. Sub DeleteBlankRows() Dim oRow As Range Dim iCount As Integer With ActiveDocument For i = .Tables.Count To 1 Step -1 For j = .Tables(i).Rows.Count To 1 Step -1 Set oRow = .Tables(i).Rows(j).Range iCount = (oRow.Columns.Count * 2) + 2 If Len(oRow) = iCount Then .Tables(i).Rows(j).Delete End If Next j Next i End With End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Faraz A. Qureshi wrote: Can one of you experts kindly devise a macro for me so as to have from all the tables from the text copied to a word document from a web page, blank rows deleted. There are different tables at different locations/pages. Thanx in advance. |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
DELETING BLANK ROWS
By the way I have found that some of the cells are found to be consisting
only spaces. How to carryout the exercise for such cells with only spaces? -- Do check "Yes" if this post is helpful, Best Regards, Faraz "Graham Mayor" wrote: The following should work. Rows with merged cells will be ignored. Sub DeleteBlankRows() Dim oRow As Range Dim iCount As Integer With ActiveDocument For i = .Tables.Count To 1 Step -1 For j = .Tables(i).Rows.Count To 1 Step -1 Set oRow = .Tables(i).Rows(j).Range iCount = (oRow.Columns.Count * 2) + 2 If Len(oRow) = iCount Then .Tables(i).Rows(j).Delete End If Next j Next i End With End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Faraz A. Qureshi wrote: Can one of you experts kindly devise a macro for me so as to have from all the tables from the text copied to a word document from a web page, blank rows deleted. There are different tables at different locations/pages. Thanx in advance. |
#5
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
DELETING BLANK ROWS
If some cells only contain spaces, then you need to test each cell to remove the spaces before testing the rows eg Sub DeleteBlankRows() Dim oRow As Range Dim oCell As Cell Dim oRng As Range Dim iCount As Integer With ActiveDocument For i = .Tables.Count To 1 Step -1 For j = .Tables(i).Rows.Count To 1 Step -1 Set oRow = .Tables(i).Rows(j).Range For k = 1 To .Tables(i).Columns.Count Set oRng = .Tables(i).Cell(j, k).Range oRng.End = oRng.End - 1 For l = oRng.Characters.Count To 1 Step -1 If oRng.Characters(l) = Chr(32) Then oRng.Characters(l).Delete Else GoTo NextCell End If Next l NextCell: Next k iCount = (oRow.Columns.Count * 2) + 2 If Len(oRow) = iCount Then .Tables(i).Rows(j).Delete End If Next j Next i End With End Sub This macro will produce an error with merged cells. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Faraz A. Qureshi wrote: By the way I have found that some of the cells are found to be consisting only spaces. How to carryout the exercise for such cells with only spaces? The following should work. Rows with merged cells will be ignored. Sub DeleteBlankRows() Dim oRow As Range Dim iCount As Integer With ActiveDocument For i = .Tables.Count To 1 Step -1 For j = .Tables(i).Rows.Count To 1 Step -1 Set oRow = .Tables(i).Rows(j).Range iCount = (oRow.Columns.Count * 2) + 2 If Len(oRow) = iCount Then .Tables(i).Rows(j).Delete End If Next j Next i End With End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Faraz A. Qureshi wrote: Can one of you experts kindly devise a macro for me so as to have from all the tables from the text copied to a word document from a web page, blank rows deleted. There are different tables at different locations/pages. Thanx in advance. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Deleting blank rows / columns in a Word 2002 Table | Tables | |||
Deleting rows or columns | Tables | |||
Deleting Multiple Blank Rows (which feature two lines) in a Word D | Microsoft Word Help | |||
Deleting Blank Rows in Word | Mailmerge | |||
Deleting blank rows in all tables | Tables |