Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub MergeWithCellToRight()
- '
- ' MergeWithCellToRight Macro
- '
- '
- Dim oRng As Range
- Dim oCell As Cell
- 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
- Selection.Collapse wdCollapseStart
- End Sub
- Selection.MoveDown wdCell, 1
- Sub Merges2Cols()
- Dim nbLines As Integer
- nbLines = 10 'you'd have to count the number of lines you want to merge
- For i = 1 To nbLines
- Selection.MoveRight Unit:=wdCharacter, Count:=2, Extend:=wdExtend
- Selection.Cells.Merge
- Selection.MoveDown Unit:=wdLine, Count:=1
- Next
- End Sub
- Selection.Move Unit:=wdCell, Count:=Selection.Tables(1).Columns.Count
- Selection.Move Unit:=wdCell, Count:=-1 * Selection.Tables(1).Columns.Count
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement