How to test if a cell of a table is empty?

  • Thread starter Á÷À˵ÄË«Óã
  • Start date
Á

Á÷À˵ÄË«Óã

I want to test if a cell of a table is empty.How to do that?
Any help is appreciated.
 
G

Graham Mayor

Check whether the cell range length is = 2 e.g.

Dim oTable As Table
Dim oCell As Range
Set oTable = ActiveDocument.Tables(1)
For i = 1 To oTable.Rows.Count
For j = 1 To oTable.Columns.Count
Set oCell = oTable.Cell(i, j).Range
If Len(oCell) = 2 Then
MsgBox "Cell Row " & i & " Column " & j & " is empty"
End If
Next j
Next i


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Á

Á÷À˵ÄË«Óã

Thank you for you help.
If a cell has only tow or more paragraph marks and nothing else, this is
considered as a empty cell. However, its length is more than 2.How to solve
it?
 
M

macropod

You can test for that by changing:
If Len(oCell) = 2 Then
to:
If Len(Replace(oCell, vbCr, "")) = 1 Then
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top