+ Reply to Thread
Results 1 to 6 of 6

Checkbok Unhide/Hide

  1. #1
    Registered User
    Join Date
    08-20-2015
    Location
    Bodega Bay, CA
    MS-Off Ver
    2013
    Posts
    20

    Checkbok Unhide/Hide

    Hello experts. I have a checkbox in a sheet called "Setup". I would like to write code such that when this box is checked rows 40-46 on all sheets in the workbook that come after a sheet called "Master" are unhidden. If the box is unchecked, the rows are hidden. Thanks much.

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,520

    Re: Checkbok Unhide/Hide

    Hi there,

    Can we assume that the worksheet called "Setup" comes before (i.e. has a lower Index than) the worksheet called "Master"?

    Regards,

    Greg M

  3. #3
    Registered User
    Join Date
    08-20-2015
    Location
    Bodega Bay, CA
    MS-Off Ver
    2013
    Posts
    20

    Re: Checkbok Unhide/Hide

    The sheets are ordered Setup then Master but when I look under the Objects menu in VBA it says Sheet1 (Master), Sheet2 (Setup)...

  4. #4
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Checkbok Unhide/Hide

    Quote Originally Posted by kingewing View Post
    The sheets are ordered Setup then Master but when I look under the Objects menu in VBA it says Sheet1 (Master), Sheet2 (Setup)...
    In code when you refer to a worksheet by index.
    Worksheets(1) it refers to the order of the tabs from left to right.
    If you move the tabs around you have effectively changed the index order of the sheets.

    When you look in the VBE and you see Sheet1(Master), Sheet2(Setup)

    The name in the ( ) is the tab name of the sheet. If you change the tab name this name will change.
    The Sheet1 is the code name that Excel knows the sheet by. If you highlight one of your sheets in the VBE and choose F4 to display the properties window you will see a name property and you will see it says Sheet1 if you selected Sheet1. You can then change this name and the left hand name will change, but the tab name will stay the same. The beauty of this name is you can use it in code and it will always refer to the same sheet and you don't have to worry about someone changing the tab name and causing problems with the code. The other benefit is if you use this name intellisense is available by just typing that code name and a dot.
    Last edited by skywriter; 08-23-2015 at 05:10 PM.
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  5. #5
    Registered User
    Join Date
    08-20-2015
    Location
    Bodega Bay, CA
    MS-Off Ver
    2013
    Posts
    20

    Re: Checkbok Unhide/Hide

    Thanks. Based on that then the order is Setup then Master.

  6. #6
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,520

    Re: Checkbok Unhide/Hide

    Hi again,

    Take a look at the attached workbook and see if it does what you need. It uses the following code:

    Please Login or Register  to view this content.
    The highlighted values may be changed to suit your own workbook layout.

    Hope this helps - please let me know how you get on.

    Regards,

    Greg M
    Attached Files Attached Files
    Last edited by Greg M; 08-23-2015 at 06:16 PM. Reason: Workbook attached

+ 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 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
  2. Excel 2007 : Hide and Unhide
    By TANKERMAN in forum Excel General
    Replies: 2
    Last Post: 04-17-2012, 10:32 AM
  3. Hide/Unhide
    By jknober in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-26-2010, 05:06 PM
  4. Hide/Unhide Help
    By Danno in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-26-2006, 12:55 PM
  5. Checkbok & printing
    By in forum Excel General
    Replies: 2
    Last Post: 05-30-2006, 07:40 AM
  6. Hide and unhide
    By Marcel in forum Excel General
    Replies: 1
    Last Post: 03-10-2005, 08:06 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