+ Reply to Thread
Results 1 to 2 of 2

VBA code to hide/unhide worksheets

  1. #1
    Registered User
    Join Date
    05-11-2015
    Location
    melbourne
    MS-Off Ver
    2010
    Posts
    38

    VBA code to hide/unhide worksheets

    My sheet is like a questionnaire the user needs to tick yes or no for each topic. Some of the topics require further information so in these cases other worksheets will appear if yes is ticked.

    Some of the sheets require the same sheet to open if yes is ticked. For example 'investigations' and 'dispersive soils' both open the 'site details' worksheet if yes is ticked. My dilemma is that if no is ticked for 'dispersive soils' then I don't want 'site details' to close as it is ticked yes for 'investigations'. For any of the topics I don't want sheets to disappear if they are ticked yes elsewhere.

    I have attached my spreadsheet for reference.

    I have had help with the code below and used it in my spreadsheet the best I can but cant get it to work quite how I want . Can anyone suggest where I might be going wrong.

    Please Login or Register  to view this content.
    test 2 (3).xlsm
    Last edited by Leith Ross; 10-25-2015 at 09:35 PM.

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

    Re: VBA code to hide/unhide worksheets

    Hi there,

    I can't test your workbook as I don't have a 64-bit system installed and therefore cannot create a Reference to Windows\SysWOW64\mscomct2.ocx.

    I think the basic problem is that your code is taking actions on the basis of the Click event for each individual OptionButton, and therefore the code associated with an individual OptionButton has no way of "knowing" the worksheet requirements associated with OptionButtons which have been selected/unselected already. Perhaps a better approach would be to call the SAME routine from EACH of the various OptionButton_Click routines, immediately review the selected/unselected states of ALL OptionButtons, and then hide/unhide worksheets on the basis of the current states.

    Hope this is (a) understandable, and (b) helpful - please let me know how you get on.

    Regards,

    Greg M

+ 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. VBA to hide/ unhide worksheets
    By holli in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-18-2015, 08:10 PM
  2. Hide and Unhide Worksheets
    By ExcelNel101 in forum Excel General
    Replies: 5
    Last Post: 03-06-2015, 06:15 AM
  3. Hide Unhide Worksheets VBA
    By Playemgraeme in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-30-2014, 04:31 PM
  4. [SOLVED] PW Protected Macros Needed to 1) Hide Certain Worksheets & 2) Unhide Worksheets & Columns
    By Aimee S. in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-21-2014, 10:49 AM
  5. [SOLVED] Can hide/unhide or add worksheets
    By govcam in forum Excel General
    Replies: 5
    Last Post: 04-08-2014, 08:20 PM
  6. Help with VBA Code (Hide/Unhide Worksheets)
    By maryren in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-21-2014, 12:43 PM
  7. Hide and/or Unhide Worksheets
    By Rob in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-13-2006, 04:35 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