A family of Microsoft word processing software products for creating web, email, and print documents.
Well, yes an no.
If you have only vertically merged cells we can detect them, but if there is just one horizontal merged cell you are lost.
Make a new file, create table with 5 columns and 3 rows and execute the macro below. You can see the row/column number of each cell in the MsgBox.
Now try to merge cells vertically and run the macro again. You can see a "X|X" at the position where a cell is missing. Theoretically we can use the cell above the "X|X" and split them into rows.
But now merge just 2 cells horizontally and run the macro again. No chance anymore.
Andreas.
Sub Test()
Dim i As Long, j As Long
Dim Data()
Dim T As Table
Dim C As Cell
Dim S As String
If Not Selection.Information(wdWithInTable) Then
MsgBox "Selection is not within a table"
Exit Sub
End If
Set T = Selection.Tables(1)
With T
'Build array for each cell
ReDim Data(1 To .Rows.Count, 1 To .Columns.Count)
'Start with the first cell
Set C = .Cell(1, 1)
'Visit all cells
Do While Not C Is Nothing
'Write the row and column into out array
Data(C.RowIndex, C.ColumnIndex) = C.RowIndex & "," & C.ColumnIndex
'Get the next cell
Set C = C.Next
Loop
'Build a string with the row/columns from our array
For i = 1 To UBound(Data)
For j = 1 To UBound(Data, 2)
S = S & IIf(IsEmpty(Data(i, j)), "X,X", Data(i, j)) & "|"
Next
S = S & vbCrLf
Next
MsgBox S
End With
End Sub