Ask Your Question
0

Calc - Merge Down Macro

asked 2017-07-29 15:03:09 +0200

ciaron88 gravatar image

Hi

what i want is to only merge columns in a selected range, like the Merge Across Tool in excel but with columns instead. i have seen a previous question Merge Across Tool and i have tried to adapt the code by mark_t but it is still merging rows.

My code:

REM  *****  BASIC  *****

Option Explicit

Sub MergeDown

Dim oCurSelection As Object
Dim oSelRangeAddress As New com.sun.star.table.CellRangeAddress
Dim i As Long

oCurSelection = thisComponent.CurrentSelection
oSelRangeAddress = oCurSelection.RangeAddress

If oSelRangeAddress.EndRow < oSelRangeAddress.StartRow + 1 Then
    msgbox  "There are no rows to merge."
    Exit Sub
End If

For i = oSelRangeAddress.StartColumn to oSelRangeAddress.EndColumn
    oCurSelection.Spreadsheet. _
        getCellRangeByPosition(oSelRangeAddress.StartRow, i, oSelRangeAddress.EndRow, i). _
        merge(True)
Next i

End Sub

Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2017-07-29 15:52:12 +0200

librebel gravatar image

Hello @ciaron88,

you could try: oCurSelection.Spreadsheet.getCellRangeByPosition(i, oSelRangeAddress.StartRow, i, oSelRangeAddress.EndRow).merge(True)

edit flag offensive delete link more

Comments

Thanks. it now works

ciaron88 gravatar imageciaron88 ( 2017-07-29 20:13:56 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-07-29 15:03:09 +0200

Seen: 139 times

Last updated: Jul 29 '17