A macro button that specifically shows and hides a number of rows

Can someone please help me?
I want to create a button that allows me to hide/show row 14 to row 18.
I succeeded. With columns, but with rows. It appears to be a different story.

1 Like

Crossposted at OpenOffice forum.

If you cross post, as a courtesy please let us know that you have done so, otherwise it leads to several discussions and a waste of time because several identical answers may be posted by different users.

Also, you can do it without macros.
Menu/Data/Group
https://help.libreoffice.org/24.8/en-US/text/scalc/01/12080300.html?System=WIN&DbPAR=CALC&HID=.uno:Group#bm_id9177845

https://documentation.libreoffice.org/en/english-documentation/

2 Likes

There is also an enhanced version of the example I posted in the other site with macros that can toggle the visibility of the rows belonging to a range one by one.
aoo111475ToggleVisibilityForRowRangesByClickingPushbuttonsEnhanced.ods (22.1 KB)

1 Like

Oh, my apologies, I did not know that this had to be mentioned. Exactly. I have to. Close the post there. At least if I can find it again.

Do you know the grouping feature (key F12)?
group_levels.ods (17.0 KB)

1 Like
	doc = ThisComponent
	sheet = doc.CurrentController.ActiveSheet
	range = sheet.getCellRangeByName("A14:A18")
	range.Rows.IsVisible = Not range.Rows.IsVisible
1 Like

That’s fast. Thank you very much indeed. I’m going to try it out until early tomorrow morning. It’s very late here now in the Netherlands. haha

I was so excited that I immediately tried it and it works fantastic. Thank you very much. Now I can continue with the accounting.