MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

unhide a page if a cell b4 equals 5 in excel

  Asked By: Muaz    Date: Nov 22    Category: MS Office    Views: 856

I have a spreadsheet with a hidden page.

If cell B4 = 5 r above I wish the page (sheet 2) to be unhidden
also if then falls value in B4 goes below 5 I would then like to hide the sheet.



3 Answers Found

Answer #1    Answered By: Mona Wagner     Answered On: Nov 22

I assume cell  B4 on Sheet2 has a formula, so its value may change automatically
based on other cells, the time, etc. Paste the following event logic in the code
module for Sheet2:

Private Sub Worksheet_Calculate()
If Me.Range("B4") < 5 Then Me.Visible = False
If Me.Range("B4") >= 5 Then Me.Visible = True
End Sub

This code will run whenever Sheet2 is recalculated. To ensure that B4 always
get recalculated, you can add +(0*Now()) to the end of the formula in B4. It
won't change the value of B4, but the Now() function guarantees that excel  will
recalc B4 when the workbook is recalculated.

If you're new to macros, you may want to read David McRitchie's intro at:

Answer #2    Answered By: Eloise Lawrence     Answered On: Nov 22

wow that is a lot easier than what i was going to suggest.. i was starting to
work on the worksheet on change event.... yours is much easier/better.. thanks

Answer #3    Answered By: Doyle Gonzalez     Answered On: Nov 22

Thanks very much, I have been going round in circles today.
Keep up the good work

Didn't find what you were looking for? Find more on unhide a page if a cell b4 equals 5 in excel Or get search suggestion and latest updates.