+ Reply to Thread
Results 1 to 6 of 6

Macro that hides/unhides sheets depending on cell value

  1. #1
    Registered User
    Join Date
    01-12-2011
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    11

    Macro that hides/unhides sheets depending on cell value

    Hi

    My knowledge of VB is pretty limited and I have tried with no success to find a macro that will unhide/hide sheets depending on a returned value in once particular cell. I have pretty much read every forum post and am still stumped.

    So far I have got this but I know that Worksheet_Change doesn't run when the value of the target cell contains a formula (an IF "true or false" formula)

    Please Login or Register  to view this content.
    I have looked at Worksheet_Calculate but just don't know what to go.

    Any help would be much appreciated.
    Thanks
    Ben
    Last edited by DonkeyOte; 01-13-2011 at 05:10 AM. Reason: CODE tags please...

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Macro that hides/unhides sheets depending on cell value

    A calculate event would work like this:

    Please Login or Register  to view this content.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Macro that hides/unhides sheets depending on cell value

    @Ben, welcome to the Board, please remember to always encase VBA within CODE tags - given first post I've modified for you on this occasion.
    Please be sure to check out the Forum Rules

    You are correct that you would need to use the Calculate event - but obviously this has no Target per se and will fire for any number of reasons (not just because B59 has altered).

    You could in theory use:

    Please Login or Register  to view this content.
    in the above I assumed by "TRUE" you mean is TRUE
    (a Boolean as opposed to a text string)

  4. #4
    Registered User
    Join Date
    01-12-2011
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Macro that hides/unhides sheets depending on cell value

    Thanks guys, and soz for the oversight Donkey.

    Dom - I have tried using that macro and it works the first time the formula returns TRUE i.e. to unhide sheets, but has problems when it changes to FALSE. I don't want to hide and unhide exactly the same sheets.

    This is how mine reads:

    Please Login or Register  to view this content.

    I'm really stumped with this...

    Thanks
    Ben
    Last edited by amelio; 01-13-2011 at 06:08 AM.

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Macro that hides/unhides sheets depending on cell value

    From what I can tell only a handful of those sheets have their visibility altered

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    01-12-2011
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Macro that hides/unhides sheets depending on cell value

    Perfect....Thank you Donkey. I don't really understand the code but it works a treat.

    Cheers Mate!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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