#1   Report Post  
Posted to microsoft.public.word.docmanagement
Faraz A. Qureshi Faraz A. Qureshi is offline
external usenet poster
 
Posts: 12
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Faraz A. Qureshi Faraz A. Qureshi is offline
external usenet poster
 
Posts: 12
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Faraz A. Qureshi Faraz A. Qureshi is offline
external usenet poster
 
Posts: 12
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting blank rows / columns in a Word 2002 Table Renegade Tables 1 April 11th 08 03:04 PM
Deleting rows or columns Rufus Tables 2 July 28th 07 12:42 AM
Deleting Multiple Blank Rows (which feature two lines) in a Word D dalovindj Microsoft Word Help 0 July 10th 06 06:43 PM
Deleting Blank Rows in Word [email protected] Mailmerge 1 July 4th 05 08:40 PM
Deleting blank rows in all tables KWC via OfficeKB.com Tables 2 June 24th 05 05:33 PM


All times are GMT +1. The time now is 05:50 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"