Page 1 of 1

[Solved] How to get range of merged cells

PostPosted: Thu Jan 17, 2019 4:16 pm
by VBandOoffice
Hi all,
I need to know, weather some cells of a spreadsheet are merged together or not.
If I define a range and look to isMerged or use getIsMerged, then I get TRUE, even if only the first two cells from ten cells are merged together.
Only if there are no cells at all merged, isMerged will be read FALSE.

Do anyone know about this - and how to work around? I'm using LibreOffice 6.1.4 and Windows7

Best regards,
VBandOoffice

Re: How to get range of merged cells

PostPosted: Thu Jan 17, 2019 5:10 pm
by Lupp

Re: How to get range of merged cells

PostPosted: Fri Jan 18, 2019 10:28 am
by VBandOoffice
Hello Lupp,

with the code from Villeroy (Sub fillMergedAreas(oRange, oRanges)) I only get all StartCells of merged cells correctly, but the range is not matching the real merged range.
If there are some unmerged cells between the merged ranges, I will not detect them.

Some Ideas why? - And how to get the real merged range?

Best regards,
VBandOoffice

Re: How to get range of merged cells

PostPosted: Fri Jan 18, 2019 5:28 pm
by Villeroy
In the attached file (selectMerged.ods) you find a function that returns the merged region of a start cell.
In fact the macro in that document selects all the regions. The code snippet in the other posting is faster since it does not do that.

Re: How to get range of merged cells

PostPosted: Fri Jan 18, 2019 11:02 pm
by JeJe
My oops.

Re: How to get range of merged cells

PostPosted: Tue Jan 22, 2019 3:45 pm
by VBandOoffice
Hi all,

it works!

Thank you Villeroy!

Best regards to all,
VBandOoffice