+ Reply to Thread
Results 1 to 4 of 4

Hide Unhide worksheets conditionally

Hybrid View

  1. #1
    Registered User
    Join Date
    05-02-2012
    Location
    Indiana
    MS-Off Ver
    Excel 2007
    Posts
    33

    Hide Unhide worksheets conditionally

    I have a workbook with 200 worksheets.
    These change names with every new use, as each tab is renamed with a macro that referes to cell A9 in each worksheet.
    I would like to write a macro that when the button is clicked, it hides all sheets that have the value "0" in cell A9, and unhides any that do not have "0" in A9.
    I have searched this forum for a couple of days, and have mixed and tried to match codes to do this, but It seems that I am getting nowhere.
    Any suggestions on how to accomplish this task?
    All help and suggestions are very appreciated.
    Thank you

  2. #2
    Forum Contributor
    Join Date
    11-26-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    159

    Re: Hide Unhide worksheets conditionally

    Hi

    insert button and right click on assign macro and paste below code in VB editor

    try dis code.

    
    Sub Button1_Click()
    Dim ws As Worksheet
    For Each ws In Sheets
     If ws.Range("A9").Value = 0 Then
        ws.Visible = xlSheetVeryHidden
     Else
        ws.Visible = xlSheetVisible
      End If
        
        Next ws    
    End Sub
    Last edited by mmmarks; 07-19-2012 at 07:52 AM.

  3. #3
    Registered User
    Join Date
    05-02-2012
    Location
    Indiana
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: Hide Unhide worksheets conditionally

    Thank You
    This is exactly what I've been trying to accomplish.

  4. #4
    Forum Contributor
    Join Date
    11-26-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    159

    Re: Hide Unhide worksheets conditionally

    Quote Originally Posted by ufopilot3 View Post
    Thank You
    This is exactly what I've been trying to accomplish.
    I glad that I helped U

+ 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