From: David Newmarch on 11 May 2010 05:12 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 11 May 2010 05:45 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 11 May 2010 07:58 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 11 May 2010 08:32 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? >> >> >> . >>
|
Pages: 1 Prev: Using the Office 2007 Suite on a second computer Next: Why can't I see shading on my screen? |