VBA code to hide/unhide rows that have a "1" in column A - 32 sheets
Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: VBA code to hide/unhide rows that have a "1" in column A - 32 sheets

  1. #11
    New Member
    Join Date
    Mar 2019
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA code to hide/unhide rows that have a "1" in column A - 32 sheets

    I think you may have put the code in the wrong place (the unprotect and protect).

    Try it like this:

    Code:
    Private Sub CommandButton1_Click()
    
    Dim Sh As Worksheet
      On Error Resume Next
      For Each Sh In Worksheets
    Sh.Unprotect "Hskp19"
        Sh.Rows.Hidden = False
        Sh.Columns("A").SpecialCells(xlFormulas, xlNumbers).EntireRow.Hidden = True
    Sh.Protect "Hskp19"
      Next
      On Error GoTo 0
    End Sub
    I don't know if you need to unprotect the sheet to click the button? If so this won't work sorry.

    EDIT: D'oh just re-read your post where you clearly state you do need to unprotect it to click the button.
    And now I'm not even sure if you need to unprotect each sheet to hide the rows... probably not... Yeah just ignore this post.

    EDIT2: I've never needed to put "Password =" when using protect commands but I have always used quote marks around the password, maybe it will work if you use your code from your last post but change those two lines to:

    ActiveSheet.Unprotect "Hskp19"

    and

    ActiveSheet.Protect "Hskp19"

    EDIT3: Hopefully the last one. Just noticed something and feel stupid. If you need to unprotect to click the button, how does putting unprotect in the button_click code work? I am totally confused now.
    Last edited by Zanmato; Jul 9th, 2019 at 06:19 PM.

  2. #12
    New Member
    Join Date
    Jul 2019
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA code to hide/unhide rows that have a "1" in column A - 32 sheets

    Thank you yet again. Sorry to confuse you. I had tried a few things before sending the post then confused myself. I used the recent revision and it DOES work as necessary. I think we are good to move forward. Your help is greatly appreciated! I have tested a few different ways.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •