Detect Split or Merged Cells

G

Greg

I am trying to determine if a table contains split or merged cells. I
am close, but not there yet.

Using the following code and comparing the cell count to the the
product of the total row count and total column count, I can determine
if the table has split cells, merged cells, or a combinationof both,
provided that the combination of split and merges don't cancel each
other out.

Sub Test()
Dim oCell As Cell
Dim oColTotal&, oRowTotal&, i&, j&, k&
Dim Msg$
k = 0
For Each oCell In Selection.Tables(1).Range.Cells
i = oCell.ColumnIndex
If i > oColTotal Then oColTotal = i
j = oCell.RowIndex
If j > oRowTotal Then oRowTotal = j
k = k + 1
Next oCell
If k <> oColTotal * oRowTotal Then
MsgBox "Table contains split or merged cells."
Else
MsgBox "Table does not contain split or merged cells."
End If
End Sub

Is there some method that I am unaward of that detects split or merged
cells in a table?

Thanks.
 
G

Greg

Sometimes just asking the question springs the trap. I found something
that appears to fit the bill:

Selection.Tables(1).Uniform
 

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