+ Reply to Thread
Results 1 to 5 of 5

Hide/Unhide sheets based on text result of IF Formula in cell in another sheet

  1. #1
    Registered User
    Join Date
    11-20-2013
    Location
    Eugene, Oregon
    MS-Off Ver
    Excel 2010
    Posts
    11

    Hide/Unhide sheets based on text result of IF Formula in cell in another sheet

    Hello,

    I have a workbook with four sheets: "Main", "OutriggersSM", "OutriggersLG", and "Ref". Forum5.xlsm There are a number of different option combinations on Main, determined using combos of Y/N in cells B15, B16, E15, & E16. Depending on what the user selects on Main, Ref cell A16 will show one of four letter codes. Based on the code in A16, cell A17 will then show one of three options: blank or the text SMALL KIT or LARGE KIT. A16 and A17 function using IF formulas. (yes, I know it's a lot of IFs, sorry :D)

    If A17 shows blank, I want both the OutriggersSM & Outriggers LG sheets to be visible. If A17 shows SMALL KIT, I only want the user to see the OutriggersSM sheet (hide OutriggersLG). If A17 shows LARGE KIT, have OutriggersLG visible and OutriggersSM hidden.

    There's a lot of solutions posted online but I haven't been able to get any to work. Here's my current code in the Ref worksheet:

    Please Login or Register  to view this content.

    Also, started simple with nested IFs but obviously I should be doing this with an If-Else-Else... I'll get that figured out later.

    Thank you in advance!
    Last edited by yukinosei; 01-16-2014 at 01:19 PM. Reason: SOLVED

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Hide/Unhide sheets based on text result of IF Formula in cell in another sheet

    this is one way of doing it with the SELECT CASE method:
    Please Login or Register  to view this content.
    Here if how to make your IF work:
    Please Login or Register  to view this content.
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,600

    Re: Hide/Unhide sheets based on text result of IF Formula in cell in another sheet

    That's not a valid Worksheet Change event subroutine header. It should have a Target range reference. You use that to monitor the cell that changes, in this case, cells on the Main sheet ... So that's where your (corrected) change event needs to be. A change event is NOT triggered by a change in a formula output.

    I'd start by hiding all the sheets and then unhiding the relevant sheets depending on the value in A17. Make each IF independent and have an Exit Sub before the End If.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,600

    Re: Hide/Unhide sheets based on text result of IF Formula in cell in another sheet

    @Pierre: if the Change event is on the Ref sheet it won't work because A17 is a formula based on other cells.

    Regards, TMS

  5. #5
    Registered User
    Join Date
    11-20-2013
    Location
    Eugene, Oregon
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Hide/Unhide sheets based on text result of IF Formula in cell in another sheet

    Thanks Trevor & Pierre. Given Trevor's comment that changes aren't triggered by formula results (boo hoo!), I ended up abandoning my code in Ref worksheet and instead inputting code into Main, where the data to generate Ref!A17's value lives. Turned out simpler that way anyway...

    I can't hide all the sheets to start with because I want the user to be able to see them up front for reference. Not everyone that uses this workbook will know their inventory options in and out, so they may need to look at the LG and SM sheets to decide what they ultimately want (in an ideal world they wouldn't ). Then when they get into their project, only the relevant one will be shown. Didn't explain that, sorry.

    Added the target range reference too. Thanks, didn't realize it had gotten deleted.

    Please Login or Register  to view this content.
    Thank you both for your help!

+ 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. hide and unhide rows based on formula result
    By tjanda in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-28-2012, 04:20 AM
  2. [SOLVED] Hide/Unhide Rows Based On Cell Result
    By stockjc in forum Excel General
    Replies: 5
    Last Post: 08-29-2012, 09:37 PM
  3. Replies: 1
    Last Post: 08-21-2012, 02:46 PM
  4. Hide/Unhide rows based on cell value (result of formula)
    By tjanda in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-17-2012, 05:57 PM
  5. Auto Hide/Unhide rows in Excel based on formula result in a column
    By crozierk in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 08-12-2012, 08:02 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