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.
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