macro to merge two table cells?

  • Thread starter Thread starter David Newmarch
  • Start date Start date
D

David Newmarch

I've trying unsuccessfully to record a macro that will merge a table cell
with the cell to the right of it. Could anyone suggest code that would do
this?
 
Sub MergeCellToRight()
Dim oRng As Range
Dim oCell As Cell
Dim i As Long
Set oCell = Selection.Cells(1)
If oCell.ColumnIndex = Selection.Rows(1).Cells.Count Then
MsgBox "There is no cell to the right?", vbCritical, "Error"
Exit Sub
End If
Set oRng = oCell.Range
oRng.MoveEnd wdCell, 1
oRng.Cells.Merge
oCell.Select
Selection.Collapse wdCollapseStart
End Sub


will merge the cell containing the cursor with the cell to the right

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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
You are welcome :) Note that the line
Dim i As Long
was not actually used in the posted version of the macro and can be deleted


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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Back
Top