How can I merge cells in consecutive rows

I have an area where I need to merge all cells in every row but not across rows. The area is very tall (around 250 rows), so doing it manually for every row is not viable. If I select the whole area and merge the cells, they all merge into one tall cell.

What is a good way to merge every row in the area? The starting point is shown by the first image, and the goal is shown in the second image. The area where rows should be merged is designated by the border and continues downward.

the starting point

the goal

I realized that extending cells by dragging from the bottom right corner of a selection extends also how the cells are merged. So merging the cells in every row can be done by merging the cells in the first row, selecting it and extending it to the rest of the area. That overwrites the previous content of the area, so it may be necessary to copy the original content elsewhere before the merging and copy the content back into the merged rows.

1 Like

doesn’t it fall under the vey definition of "not viable " ? :thinking:

should be (almost) doable with a macro : Calc Macro Merge Cells

It is viable because I can copy the whole column at once.

and merge ?

Wait, what are you commenting about? The question or my answer? The content seems like you are commenting about my answer, but you post it as an answer to the question. So I am confused.

As I described in the answer, merging is done by merging the first row and extending it by dragging from the bottom right corner of the selected merged cell over the rest of the area. The complexity of that is not in O(1), but it is viable for 250 rows and much better than merging in every row separately.