+ Reply to Thread
Results 1 to 10 of 10

Click once to open, click twice to hide

  1. #1
    Registered User
    Join Date
    07-12-2016
    Location
    massachusetts
    MS-Off Ver
    excel 2010
    Posts
    44

    Click once to open, click twice to hide

    Hi, I recently had a very similar post for this request but I'm finding a few more uses for it and I'm trying to learn by seeing a few of these in action.

    The last post requested a password in order to unhide cells/unprotect sheet, and with the second click hide these same cells and protect the sheet. The code is below (credit goes to "Sktneer").

    Please Login or Register  to view this content.
    I'm looking for a new code to consolidate these two macros into one button. The first unprotects, unhides, and then protects the sheet. The second one unprotects, hides, and then protects the sheet. I do NOT want a password for this function.


    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Can anyone assist?

    Thank you!
    Last edited by coryjacques; 02-27-2018 at 05:19 PM.

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Click once to open, click twice to hide

    Try this method
    - subs to hide, unhide, protect and unprotect added
    - call those subs to avoid repeating code

    I have not included all your ranges
    - you can try to make it work with your other ranges
    - HideRows requires a RANGE attribute

    Please Login or Register  to view this content.
    Standard module
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by kev_; 02-28-2018 at 07:02 AM.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Click once to open, click twice to hide

    Combining hide/unhide and protect/unprotect:
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    07-12-2016
    Location
    massachusetts
    MS-Off Ver
    excel 2010
    Posts
    44

    Re: Click once to open, click twice to hide

    Is there a way to combine these into one sub? I'm attempting to link it to a command button

  5. #5
    Registered User
    Join Date
    07-12-2016
    Location
    massachusetts
    MS-Off Ver
    excel 2010
    Posts
    44

    Re: Click once to open, click twice to hide

    Actually, I see that the first post is two subs but one calls the other. Sorry, limited experience here. I'm having a hard time getting it to work - messing with it now.

  6. #6
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Click once to open, click twice to hide

    Post 2 contains the code and should work straight "out of the box"

  7. #7
    Registered User
    Join Date
    07-12-2016
    Location
    massachusetts
    MS-Off Ver
    excel 2010
    Posts
    44

    Re: Click once to open, click twice to hide

    I'm unable to combine these two codes into one button. Any tips?

  8. #8
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Click once to open, click twice to hide

    That is what this does
    Please Login or Register  to view this content.
    The command button toggles between Status_Change and HideSC
    - in the sample file attached to post2 - the visible row numbers clearly alternate each time you hit the button.
    What does it not do that you want?

    (my words in post#2)
    I have not included all your ranges
    - you can try to make it work with your other ranges
    - HideRows requires a RANGE attribute
    Are you struggling with adding another range to hide?

  9. #9
    Registered User
    Join Date
    07-12-2016
    Location
    massachusetts
    MS-Off Ver
    excel 2010
    Posts
    44

    Re: Click once to open, click twice to hide

    I see it working on your sheet, I just can't get it working on mine regardless of ranges added. I'd upload the sheet but unfortunately it has client sensitive data on it that would be difficult to remove.

  10. #10
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Click once to open, click twice to hide

    - test that your ranges are giving you what you think they are giving you (most likely problem area)

    Assuming that you are using these subs, add a message box
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Open Worksheet on first click Close on next click
    By 3345james in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-20-2017, 01:59 PM
  2. [SOLVED] make button single click to avoid user double click
    By Muzza1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-25-2016, 01:02 AM
  3. Macro to click a 'choose file' button on webpage, browse for a local file, and click open
    By Insaintime32 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-06-2016, 04:46 PM
  4. [SOLVED] ActiveX combobox click triggers unwanted another comboxbox click event
    By aprildu in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 12-12-2015, 10:08 AM
  5. [SOLVED] Hide And Unhide Column With One Button,,,,Once Click Hide,,,,,Again Click Unhide
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-11-2014, 07:58 AM
  6. Replies: 0
    Last Post: 03-06-2013, 12:52 PM
  7. Replies: 8
    Last Post: 01-04-2006, 12:10 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1