Creating a macro to merge cells 2

J

João

Hi,
I have this macro that was given to me on this newsgroup:

Sub TableCrunch()
Dim oTbl As Table
Dim oRow As Row
For Each oTbl In ActiveDocument.Tables
With oTbl
For Each oRow In oTbl.Rows
If oRow.Index > 3 Then
oRow.Cells(2).Range.Delete
oRow.Cells.Merge
End If
Next oRow
End With
Next oTbl
End Sub

This macro finds a table and deletes the second column
after the third row. After this, merges the cells
resulting in only one column.
I'd like to know how can I make the merge of the second
and third columns, so the first column remains unchanged.
The result is two columns instead of one.

Thanks,

João
 
J

Jay Freedman

Hi João,

Just replace the line

oRow.Cells.Merge

with this line:

oRow.Cells(2).Merge oRow.Cells(3)

The first one says to merge together all the cells in the row. The second
one says to merge the second cell into the third cell.
 

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