Forum Discussion

Pierre59's avatar
Pierre59
Copper Contributor
Aug 14, 2021

Programming button funktion in Excel sheet

Hi, I want to add a button function that opens or closes certain predefined rows or columns in my Excel sheet. 

I need this help as soon as possible. 

Thank you

Pierre59

1 Reply

  • Pierre59 

    For example, create a macro

    Sub ToggleRows11To20()
        Range("A11:A20").EntireRow.Hidden = Not Range("A11").EntireRow.Hidden
    End Sub

    Insert a button from the Form Controls section of the Controls dropdown on the Developer tab of the ribbon, and assign the above macro to it.

    You can modify the macro as needed.