+ Reply to Thread
Results 1 to 24 of 24

Hide & UnHide worksheet with commandbutton

  1. #1
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    Hide & UnHide worksheet with commandbutton

    Is this possible,and have a password to unhide the sheet?

    Sorry I was not clear on what I want to do, I want to have worksheet2 hidden on workbook open and have a commandbutton to unhide it. I want
    the commandbutton to ask for a password before it unhides the worksheet. Can it be set up to hide sheet2 when workbook closes?
    Thanks z
    Last edited by zplugger; 08-17-2012 at 10:19 PM.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Hide & UnHide worksheet with commandbutton

    Hi zplugger,

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    Re: Hide & UnHide worksheet with commandbutton

    Not sure why having posting tonight.

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Hide & UnHide worksheet with commandbutton

    Does that mean that you've got it?

  5. #5
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    Re: Hide & UnHide worksheet with commandbutton

    No I don't have it sorry, having problems replying to the thread. It only lets me see 2 replys

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Hide & UnHide worksheet with commandbutton

    Hi zplugger,

    Perhaps:

    Please Login or Register  to view this content.


    Please Login or Register  to view this content.

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Hide & UnHide worksheet with commandbutton

    Add a CommandButton from the ActiveX controls

    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  8. #8
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    Re: Hide & UnHide worksheet with commandbutton

    Not sure what I'm doing wrong Roy, when I enter the password secret it says wrong password?

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Hide & UnHide worksheet with commandbutton

    Sorry, I missed aline of code. It was early this morning


    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    08-16-2012
    Location
    Greensboro, NC
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Hide & UnHide worksheet with commandbutton

    I set up command buttons to select tabs from a Main Page tab but when I hide the tabs so users cannot see them I get an error and the command button will not go the the chosen tab. The command buttons work if the tabs are not hidden. What am I missing?

  11. #11
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Hide & UnHide worksheet with commandbutton

    Quote Originally Posted by Deed View Post
    I set up command buttons to select tabs from a Main Page tab but when I hide the tabs so users cannot see them I get an error and the command button will not go the the chosen tab. The command buttons work if the tabs are not hidden. What am I missing?
    What's this got to do with this Thread.? You should start your own.

  12. #12
    Registered User
    Join Date
    08-16-2012
    Location
    Greensboro, NC
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Hide & UnHide worksheet with commandbutton

    Opps sorry New member I didn't know I had to start a new thread

  13. #13
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    Re: Hide & UnHide worksheet with commandbutton

    Thanks RoyUK
    It will take password now,when password is correct should it unhide sheet2?

  14. #14
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    Re: Hide & UnHide worksheet with commandbutton

    Tried your code xladept and got a run time error 13

  15. #15
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Hide & UnHide worksheet with commandbutton

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  16. #16
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    Re: Hide & UnHide worksheet with commandbutton

    xladept this does nothing on my end, it does hide sheet2 on open. But you can just
    go down and unhide it. The password does nothing, I'm must be doing something wrong.

  17. #17
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Hide & UnHide worksheet with commandbutton

    The button will toggle the visible state of the sheet based on the button's caption.

    Note that it uses the sheet's very hidden property so that VBA or access to the VB Editor is required to unhide it. So lock & password protect the VBA Project when finished.

  18. #18
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Hide & UnHide worksheet with commandbutton

    Hi zplugger,

    Roy UK's code is better anyway. But my code works on my machine??

    You can just go down and unhide it?? I wasn't thinking of security - sorry.

  19. #19
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    Re: Hide & UnHide worksheet with commandbutton

    xladept did you try roys code? I just can't get it to work. I know I'm doing something wrong,put the correct password in with no luck. After the password should I be able to just go down to sheets and unhide?,or do I have to go in properties of sheet2 and unhide?

  20. #20
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Hide & UnHide worksheet with commandbutton

    Hi zplugger,

    Roy's routine depends upon the button caption - but when the caption is there, the routine works nicely.

    With Sheet2 showing, run this capper:

    Please Login or Register  to view this content.
    Then the code runs nicely! And then it is VERY hidden - so no you can't undo it as you could my code.
    Last edited by xladept; 08-17-2012 at 08:02 PM.

  21. #21
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    Re: Hide & UnHide worksheet with commandbutton

    Roy's routine depends upon the button caption , this is where I'm lost. Sometime I just don't think like I should.could you post workbbook so I can understand the code.

    Thank You

  22. #22
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Hide & UnHide worksheet with commandbutton

    Hi ZPlugger.

    Here's a Book:ZPlugger.xls

  23. #23
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    Re: Hide & UnHide worksheet with commandbutton

    Thanks xladept, Roys code works great. Looked at the code and trying to undersand how you did it. The commandbutton I get, the capit I need to look at.
    not sure what the process is.
    Thanks to all for the help.





    Z

  24. #24
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Hide & UnHide worksheet with commandbutton

    Hi Z,

    You're welcome! The capit just sets the caption. Roy is a superior programmer.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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