+ Reply to Thread
Results 1 to 16 of 16

Rows to hide/unhide when checkbox = true/false

  1. #1
    Forum Contributor
    Join Date
    04-04-2014
    Location
    Tetbury, England
    MS-Off Ver
    Excel 2010
    Posts
    254

    Rows to hide/unhide when checkbox = true/false

    Hello

    I have 10 checkboxes on a sheet called 'Coversheet'

    When let's say the first one is checked, I need row 26 on "Dashboard" to unhide, and vice versa

    Here is my code so far which isn't working:

    Please Login or Register  to view this content.
    Note, my checkboxes aren't Active X

    Thanks!

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

    Re: Rows to hide/unhide when checkbox = true/false

    Hello PDBartlett,

    Given your sample, I assume you have something in mind as per the attached sample.

    Regards.
    Attached Files Attached Files
    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] .

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Rows to hide/unhide when checkbox = true/false

    Hi, PDBartlett,

    Please Login or Register  to view this content.
    Ciao,
    Holger
    Last edited by HaHoBe; 04-30-2014 at 01:13 PM.
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Registered User
    Join Date
    12-10-2013
    Location
    Brasil
    MS-Off Ver
    2013
    Posts
    17

    Re: Rows to hide/unhide when checkbox = true/false

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    04-04-2014
    Location
    Tetbury, England
    MS-Off Ver
    Excel 2010
    Posts
    254

    Re: Rows to hide/unhide when checkbox = true/false

    Thanks Winon, works perfectly! Is there any way of shortening the code as I be adding more checkboxes?

    Fsalina that's just the code I posted?
    Last edited by PDBartlett; 05-01-2014 at 03:22 AM.

  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: Rows to hide/unhide when checkbox = true/false

    Hello PDBartlett,

    Thank you for the feedback.

    Unfortunately I cannot think of a way to make it any shorter as shown in the revised attachment.

    Regards.
    Attached Files Attached Files

  7. #7
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Rows to hide/unhide when checkbox = true/false

    Hi, PDBartlett,

    Is there any way of shortening the code as I be adding more checkboxes?
    There is a way but thatīs needing ActiveX components AFAIK: class programming. And I would prefer one UserForm handling all the action over a lot of CheckBoxes with their individual codes

    Maybe consider to get hold of the row where the checkbox is located to hide/unhide on the other sheet.
    Please Login or Register  to view this content.
    Ciao,
    Holger

  8. #8
    Forum Contributor
    Join Date
    04-04-2014
    Location
    Tetbury, England
    MS-Off Ver
    Excel 2010
    Posts
    254

    Re: Rows to hide/unhide when checkbox = true/false

    No worries, thanks for your help

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

    Re: Rows to hide/unhide when checkbox = true/false

    Hello PDBartlett,

    If you want to trade the CheckBoxes for DropDown Boxes, it would work as demonstrated in the attached sample Workbook.

    I am also sure that you have marked this thread as Solved, with the excellent contribution from HaHoBe.

    Also, since you are relatively new to the forum, I would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which you have been helped.

    This adds to the reputation of the person/s who has taken the time to help you.

    Best Regards.
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    04-04-2014
    Location
    Tetbury, England
    MS-Off Ver
    Excel 2010
    Posts
    254

    Re: Rows to hide/unhide when checkbox = true/false

    I've stuck with your initial code, Winon, but could you help me with this:

    I've added the following code to uncheck all checkboxes:

    Please Login or Register  to view this content.
    But when it runs, the rows that should then hide because the checkboxes aren't ticked aren't hidden.. they just don't do anything?

    I don't understand why

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

    Re: Rows to hide/unhide when checkbox = true/false

    Hi PDBartlett,

    Thanks for the feedback.

    With the sample Workbook as per Post#6.

    If you want to clear the Checkboxes, you have to tell VBA to keep the hidden Rows in the Dashboard Sheet as is, as follows:

    Please Login or Register  to view this content.
    Regards.

  12. #12
    Forum Contributor
    Join Date
    04-04-2014
    Location
    Tetbury, England
    MS-Off Ver
    Excel 2010
    Posts
    254

    Re: Rows to hide/unhide when checkbox = true/false

    Hi Winon

    Thanks for that.

    The code I now have works if all the checkboxes are selected, but if only a few are selected and I run the macro, I get the message:

    Unable to set the Hidden property of the Range class

    My code:

    Please Login or Register  to view this content.
    Would it be some kind of If statement?

  13. #13
    Forum Contributor
    Join Date
    04-04-2014
    Location
    Tetbury, England
    MS-Off Ver
    Excel 2010
    Posts
    254

    Re: Rows to hide/unhide when checkbox = true/false

    Hi Winon

    Thanks for that.

    The code I now have works if all the checkboxes are selected, but if only a few are selected and I run the macro, I get the message:

    Unable to set the Hidden property of the Range class

    My code:

    Please Login or Register  to view this content.
    Would it be some kind of If statement?

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

    Re: Rows to hide/unhide when checkbox = true/false

    Hi PDBartlett,

    Have you not perhaps protected the Sheets? If it is the case then change your code:

    Please Login or Register  to view this content.
    Regards

  15. #15
    Forum Contributor
    Join Date
    04-04-2014
    Location
    Tetbury, England
    MS-Off Ver
    Excel 2010
    Posts
    254

    Re: Rows to hide/unhide when checkbox = true/false

    Excellent! So simple haha

    Think I can mark this as solved now, thanks for your help

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

    Re: Rows to hide/unhide when checkbox = true/false

    Hello PDBartlett,


    Thank you for the feedback.

    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. Checkbox to hide and unhide rows
    By xjenniex in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-08-2014, 04:42 PM
  2. [SOLVED] VBA code to hide/unhide sheets based on a tick-box (TRUE/FALSE)
    By kavindra in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-10-2013, 08:11 AM
  3. 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
  4. hide/unhide rows using checkbox
    By elfirahayu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-20-2010, 03:31 PM
  5. Hide / unhide rows with help of a checkbox
    By Hansa in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-03-2009, 12:56 PM

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