+ Reply to Thread
Results 1 to 8 of 8

Hide and Unhide sheet based on Checkbox status

  1. #1
    Forum Contributor
    Join Date
    03-08-2011
    Location
    London
    MS-Off Ver
    Work Office 365 Home 2019
    Posts
    428

    Hide and Unhide sheet based on Checkbox status

    Hi Guys,

    There's a part of me that thinks this should be straightforward.

    What I'm looking to achieve is that when the Checkbox on the DSR sheet is checked, the sheet called "MOTP is unhidden (and cell b2 of MOTP is selected)

    If the Checkbox on the DSR sheet is unchecked, the sheet MOTP is cleared of any date entered and hidden (for the purposes of this exercise, let's assume data has been input in to cells B4, B6 and B9 of the MOTP sheet).

    I've tried assigning the check box to a cell and activating macro's based on the "TRUE", "FALSE" value, but I couldn't get it to work.

    Any help will be very welcome.

    Magic Man
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    08-08-2019
    Location
    Indiana
    MS-Off Ver
    2010
    Posts
    3

    Re: Hide and Unhide sheet based on Checkbox status

    Try the following:

    Create an Active X check box and apply the following code to it:

    Please Login or Register  to view this content.
    Change the red text in the above code to match the name of the check box you inserted.

    Then add the following to a new module:

    Please Login or Register  to view this content.
    The first line of the HideMOTP code is not really necessary, but I like to throw it in there to make sure that sheet is always visible before the rest of the macro tries to run. Otherwise, if you have manually hidden the tab and try to run the macro, you will get an error.

    You can obviously change the range you are selecting in the HideMOTP macro in order to clear more than just the three specific cells you mentioned for your example.
    Last edited by maurithegreat; 08-30-2019 at 01:17 PM.

  3. #3
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,110

    Re: Hide and Unhide sheet based on Checkbox status

    How about
    Please Login or Register  to view this content.
    Simply assign this to the forms control checkbox.

  4. #4
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Hide and Unhide sheet based on Checkbox status

    Hello MagicMan,

    The CheckBox in your Workbook is a Forms Control CheckBox and not an Active X CheckBox. The CheckBox showes as CheckBox 4.

    In a Standard Module enter the Code Below and, assign a Macro to run from that same Module.

    Please Login or Register  to view this content.
    Try the attached sample.

    Regards.
    Attached Files Attached Files
    Last edited by Winon; 08-30-2019 at 01:29 PM. Reason: Forgot about Range B2
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  5. #5
    Registered User
    Join Date
    08-08-2019
    Location
    Indiana
    MS-Off Ver
    2010
    Posts
    3

    Re: Hide and Unhide sheet based on Checkbox status

    I was just in the middle of typing something similar as an alternative. You beat me to it

    Quote Originally Posted by Fluff13 View Post
    How about
    Please Login or Register  to view this content.
    Simply assign this to the forms control checkbox.

  6. #6
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Hide and Unhide sheet based on Checkbox status

    Hello MagicMan,

    Murphy is playing silly bugger with me!

    Here is the correct Code:

    Please Login or Register  to view this content.
    Regards
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    03-08-2011
    Location
    London
    MS-Off Ver
    Work Office 365 Home 2019
    Posts
    428

    Re: Hide and Unhide sheet based on Checkbox status

    Hi Winon,

    Apologies for the delay in responding. That's perfect, thank you. Rep added

  8. #8
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Hide and Unhide sheet based on Checkbox status

    Thank you for the feedback and Rep+, MagicMan,

    You are welcome. Glad I could help!

    Regards.

+ 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. [SOLVED] Hide/unhide based on ComboBox value and CheckBox value
    By Rzzberry in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 07-31-2017, 11:54 AM
  2. Hide/unhide 2 columns based on checkbox
    By horsefish01 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-12-2015, 03:27 AM
  3. Hide/Unhide Rows based on column data using checkbox
    By ricklberry in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-27-2015, 11:39 AM
  4. Hide and Unhide worksheets based on checkbox Tick
    By TwistedFaith in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-14-2015, 01:23 PM
  5. [SOLVED] Hide/unhide Cell contents based on checkbox
    By Kelton in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-25-2014, 04:25 PM
  6. Checkbox macros hide and unhide on another sheet
    By jasonexcels in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-23-2012, 11:13 AM
  7. Hide/Unhide rows with a checkbox on a different sheet
    By blah54 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-15-2012, 11:26 AM

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