+ Reply to Thread
Results 1 to 2 of 2

Hide a Tab Depending on Cell Value

Hybrid View

  1. #1
    Registered User
    Join Date
    04-19-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2007
    Posts
    3

    Hide a Tab Depending on Cell Value

    Hello,

    I want to hide SheetB when the value of cell B2 in SheetA is not 0. Cell B2 in Sheet A is a formula.

    I came with the following code that I put in sheetA's code, but it doesn't work, nothing happens. Could anyone help me?

    Thank You,
    Julien


    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("B2")) Is Nothing Then
    Sheets("SheetB").Select
    With ActiveSheet
    .Unprotect "password"
    .Visible = (sheets("SheetA").Range("B2") = 0)
    .EnableSelection = xlUnlockedCells
    .Protect "password", True
    End With
    Sheets("SheetA").Select
    End If
    End Sub

  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: Hide a Tab Depending on Cell Value

    Hi,

    As B2 on Sheet A is a formula and not a cell that is changed by the user a worksheet change event testing that cell won't work. You either need to test the a cell that the user changes which causes the formula to update or use a worksheet calculate event.

    Please use code tags when posting code per the forum rules.

    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.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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