Friday, December 14, 2018

Killer Excel Macro : A Button to Toggle Hide/Unhide of Rows

  • Start with a file that's already named .xlsm . Save time later :)
  • Know which rows? Say 10 to 12 (inclusive)
  • Right click on the name of the Sheet on the bottom of the Excel window and choose "View Code"
  • Now, paste :
Sub sbHidingUnHideRows()
    If Rows("10").EntireRow.Hidden Then
    'To unHide Rows 10 to 12
        Rows("10:12").EntireRow.Hidden = False
    Else
    'To Hide Rows 10 to 12
        Rows("10:12").EntireRow.Hidden = True
    End If
End Sub

  • And tweak it to be what you want. Then, do ALT-Q. If you go into Macros, you'll see this one..
  • Then, to create the button, go to Insert (File, Home, Insert, Draw, on the top of the Excel window)
  • Here, choose Shapes and put down something nice. Remember da Vinci : Simplicity is the ultimate sophistication.
  • Edit the Text associated with this shape.
  • Then, right-click on the shape and choose Assign Macro, pick the one you just created. And..
  • You're in business.. 

No comments: