From: David Newmarch on
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?
From: Graham Mayor on
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
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


"David Newmarch" <DavidNewmarch(a)discussions.microsoft.com> wrote in message
news:D9E2F9CC-33E4-489F-BA68-2B7C44D85431(a)microsoft.com...
> 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?


From: David Newmarch on
Beautiful. Works like a charm. Thank you very much!

"Graham Mayor" wrote:

> 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
> Word MVP web site http://word.mvps.org
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>
>
> "David Newmarch" <DavidNewmarch(a)discussions.microsoft.com> wrote in message
> news:D9E2F9CC-33E4-489F-BA68-2B7C44D85431(a)microsoft.com...
> > 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?
>
>
> .
>
From: Graham Mayor on
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
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

"David Newmarch" <DavidNewmarch(a)discussions.microsoft.com> wrote in message
news:BA1272A8-FEC9-4229-953D-AB5EFD150463(a)microsoft.com...
> Beautiful. Works like a charm. Thank you very much!
>
> "Graham Mayor" wrote:
>
>> 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
>> Word MVP web site http://word.mvps.org
>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>>
>>
>> "David Newmarch" <DavidNewmarch(a)discussions.microsoft.com> wrote in
>> message
>> news:D9E2F9CC-33E4-489F-BA68-2B7C44D85431(a)microsoft.com...
>> > 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?
>>
>>
>> .
>>