View Single Post
  #6   Report Post  
Posted to microsoft.public.word.tables
Greg Maxey Greg Maxey is offline
external usenet poster
 
Posts: 171
Default Deleting multiples BLANK cells

I just threw this together so please test on a copy of your document
first:

Sub RefillTable()
Dim myArray() As String
Dim oTbl As Word.Table
Dim cCnt As Long
Dim i As Long
Dim txtCnt As Long
Dim oRng As Word.Range
Set oTbl = Selection.Tables(1)
cCnt = oTbl.Range.Cells.Count
ReDim myArray(cCnt - 1)
txtCnt = 0
For i = 1 To cCnt
Set oRng = oTbl.Range.Cells(i).Range
If oTbl.Range.Cells(i).Range.Text Chr(13) & Chr(7) Then
oRng.MoveEndWhile Cset:=Chr(13) & Chr(7), Count:=wdBackward
myArray(txtCnt) = oRng.Text
txtCnt = txtCnt + 1
oRng.Delete
End If
Set oRng = Nothing
Next
ReDim Preserve myArray(txtCnt)
For i = 0 To txtCnt
oTbl.Range.Cells(i + 1).Range.Text = myArray(i)
Next i
End Sub

On Jan 30, 8:09 am, delage wrote:
Hi, I have a very - veeery huge table, which became from an Excell worksheet.
But I have, in the past, removed the contents of several cells which are bank
now. As this document is in fact a label archive, now when I print it, there
is a lot of blank labels in the middle of the documet. I have tried to delent
ONLY the blank fields, but the only way I found is deleting one in eache
time, - and I have more that 300 blank cells!!! How can I do to delete the
blank cells, all in one time, maintaining the structure and shape of the
table, to be sure that labels will be perfectly printed in the future - but
without the blank labels?