title: How to delete blank rows or rows with spaces in a table that has one or more cells vertically merged?
body: <p>I need a vba script or help on what I'm writing in order not to exit the iteration when the table contains <strong>vertically and horizontally merged cells</strong>.</p>
  
  <p>Example of the table:</p>
  
  <pre><code>---------
  |   |   | &lt;-- I don't want these rows deleted, they can be skipped
  |---|   |
  |   |   | &lt;-- I don't want these rows deleted, they can be skipped
  |---|---|
  |   |   | &lt;-- this must be checked for emptiness in order to decide to delete or not
  |---|---|
  |   |   | &lt;-- this must be checked for emptiness in order to decide to delete or not
  |---|---|
  </code></pre>
  
  <p>My script in VBA so far:</p>
  
  <pre><code>Public Sub DeleteEmptyRows()
      Dim c As String
      c = ""
      Dim oTable As Table, oRow As Integer
      ' Specify which table you want to work on.
      For Each oTable In ActiveDocument.Tables
  
          For oRow = oTable.Rows.Count To 1 Step -1
              'On Error GoTo NextIteration
              MsgBox oTable.Rows(oRow).Range.Text
              'If Len(oTable.Rows(oRow).Range.Text) = oTable.Rows(oRow).Cells.Count * 2 + 2 Then
              If Len(Replace(oTable.Rows(oRow).Range.Text, Chr(13) &amp; Chr(7), vbNullString)) = 0 Then
                  oTable.Rows(oRow).Delete
              End If
          Next oRow
      Next oTable
      MsgBox c
  End Sub
  </code></pre>
  
  <p>How to reproduce the error:
  Create a 5x5 table. Select cell(0,0) and cell(1, 0) and merge them. Select cell(0, 1) and cell(0, 2) and merge. Run the script and get the 5991 error..</p>
  
  <p>The problem is that I get a run-time error 5991: Can't access to individual lines in this collection because there are vertically merged cells.</p>
  
  <p>I really don't know what to do because if this error happens no row will be looked after. Usually my tables have a header that has vertically merged cells and the body rows are not, so I cannot do anything...</p>
  
  <p>for Word.</p>