+ Reply to Thread
Results 1 to 10 of 10

Macro to hide a sheet if a value on that sheet is 0

  1. #1
    Forum Contributor
    Join Date
    08-03-2005
    Posts
    272

    Macro to hide a sheet if a value on that sheet is 0

    Hi,

    I have a sheet, call it summary, that I need filled out if a value on it in A1 is not 0. Summary is linked to other sheets and inputs on those other sheets makes A1 change. So what I am looking for is a way to make summary appear if the value of A1 <> 0. If A1 goes back to 0 I need summary to hide itself again.

    Thanks for any help

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Try using this code in the WorkBook_SheetCalculate event. Each time a sheet calculates it will unhide Sheet1 if the required value changes to 0

    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Contributor
    Join Date
    08-03-2005
    Posts
    272
    Quote Originally Posted by royUK
    Try using this code in the WorkBook_SheetCalculate event. Each time a sheet calculates it will unhide Sheet1 if the required value changes to 0

    Please Login or Register  to view this content.
    Thank you so much, how do I use this in the "WorkBook_SheetCalculate event", where do I find that event. I stuck it in the code for my summary sheet, is that not right?

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    You need to click on ThisWorkBook in the VB Editor Project Window, then look in the right hand drop down to find the correct Procedure.

  5. #5
    Forum Contributor
    Join Date
    08-03-2005
    Posts
    272
    Quote Originally Posted by royUK
    You need to click on ThisWorkBook in the VB Editor Project Window, then look in the right hand drop down to find the correct Procedure.
    Sorry, but after clicking this workbook I only see General and below that Workbook, and then right of that is (Declarations).

    What am I missing?

  6. #6
    Registered User
    Join Date
    04-02-2008
    Posts
    3
    Select Workbook from the left hand drop down.

    This should set the right hand drop down to "Activate"; now select SheetCalculate from the right hand drop down.

  7. #7
    Forum Contributor
    Join Date
    08-03-2005
    Posts
    272
    Quote Originally Posted by there_is_no_bob
    Select Workbook from the left hand drop down.

    This should set the right hand drop down to "Activate"; now select SheetCalculate from the right hand drop down.

    Ok, the screen flashes like it is doing something, but the sheed won't disappear. The cell I am actually using is AR8 so I took your code and changed it to...


    Please Login or Register  to view this content.
    Is that correct?

    By the way, you taught me something new with the sheet calculate, thanks

  8. #8
    Forum Contributor
    Join Date
    08-03-2005
    Posts
    272
    Duhh!

    I needed to change Sheet1 to my sheet name. Thanks for your help.

  9. #9
    Forum Contributor
    Join Date
    08-03-2005
    Posts
    272
    I had a similar question here:

    http://www.ozgrid.com/forum/showthread.php?t=87467

    The question has been answered, thanks all.

  10. #10
    Registered User
    Join Date
    06-04-2009
    Location
    Jhb, South Africa
    MS-Off Ver
    Excel 2003/07
    Posts
    4

    Re: Macro to hide a sheet if a value on that sheet is 0

    Quote Originally Posted by royUK View Post
    Try using this code in the WorkBook_SheetCalculate event. Each time a sheet calculates it will unhide Sheet1 if the required value changes to 0

    Please Login or Register  to view this content.
    Hi, I am relatively new to VBA..

    I would like to do a similar thing to above, I would like to hide or show the sheet depending on weather or not a date displays in an array... I am using a macro I found here this to make the calendar.

    Is there any way to hide the corresponding day's sheet if there is no date returned in the array?
    Last edited by markellis88; 06-04-2009 at 07:02 AM. Reason: Fixed Link

+ 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