• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Same button to reverse macro VBA

ALAMZEB

Member
Hi
Can I use same button to reverse macro
In attached example, if I click HIDE button it hides, but want to unhide if Its clicked again.
Much appreciates
Thanks in advance
 

Attachments

  • Macro Button.xlsm
    16.8 KB · Views: 6
Hi Alamzeb

Change the button to a command button. This makes the coding a bit more straight forward. Named the commandbutton cbB1.

Code:
Private Sub cmdB1_Click()
    If cmdB1.Caption = "Unhide" Then
      Rows("7:16").EntireRow.Hidden = False
      cmdB1.Caption = "Hide"
    Else: Rows("7:16").EntireRow.Hidden = True
      cmdB1.Caption = "Unhide"
  End If
End Sub

File attached to show workings.

Take care

Smallman
 

Attachments

  • MacroButton.xlsm
    20.2 KB · Views: 7
Last edited:
Back
Top