![]() |
|
|
|
#1
|
|||
|
|||
|
Hi,
Please find the attached document. We merge this document in a application and it prepopulates the information in the cells. If there is no information - then it comes as blank. Is it possible to develop a macro or something like that - to delete the entire rows of the tables; if there is no information populated in the cells - meaning all (fillable cells in a row are blank then delete the entire row). Regards Umesh Banga |
|
#2
|
|||
|
|||
|
Code:
Sub ScratchMacro()
'A quick macro scratch pad created by Greg Maxey
Dim i As Long
Dim lngCount As Long
For i = ActiveDocument.Tables(1).Rows.Count To 1 Step -1
lngCount = ActiveDocument.Tables(1).Rows(i).Cells.Count * 2 + 2
If Len(ActiveDocument.Tables(1).Rows(i).Range.Text) = lngCount Then
ActiveDocument.Tables(1).Rows(i).Delete
End If
Next
End Sub
Last edited by macropod; 09-04-2012 at 08:22 PM. Reason: Added code tags & formatting |
|
#3
|
||||
|
||||
|
Umesh,
I have previously provided you with a quite extensive macro that includes, amongst other things, code for deleting blank rows. Rather than simply treating this forum as a free coding resource, it would be better if you invested some time in seeing how previously solutions might be adapted to new situations. Of course, we're always here to help if you get stuck.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#4
|
|||
|
|||
|
Hi,
I have tried the code but due to the table having vertically merged cell (the first column) it is throwing the error (see attached). Anyone got the solution for the debug issue? |
|
#5
|
||||
|
||||
|
Your attached document really isn't amenable to a simple deletion of empty rows. With vertically merged cells in the first two columns, spanning different rows, and vertically split cells in the remaining two columns, it becomes somewhat challenging to determine what constitutes a 'row' in a given instance (in fact, it's generally not a row you're dealing with at all but a series of cells within a row) and which cells should be deleted.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Macro to delete rows with all empty cells
|
ubns | Excel Programming | 2 | 08-14-2012 02:01 AM |
VBA and hyperlinks in table cells
|
viuf | PowerPoint | 13 | 02-19-2012 10:34 AM |
Word VBA: add textboxs in table cells?
|
tinfanide | Word VBA | 12 | 02-09-2012 12:05 AM |
put a border around table cells that have text in them
|
tonywatsonmail | Mail Merge | 1 | 01-31-2012 04:37 AM |
Combining Text from Table Cells
|
robmorleyuk | Word | 1 | 11-01-2011 07:24 AM |