+ Reply to Thread
Results 1 to 3 of 3

VBA to hide worksheets based on cell value

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    VBA to hide worksheets based on cell value

    Hello,

    I'm looking for a vba that can look up any visible/invicible worksheets then decided to hide or unhide the worksheets based on cell G1 from sheets "Report Builder". For example, if cell G1 from sheets(Report Builder) says Discrete Customers. It will hide any other sheets only display sheets "Report Builder" and Sheets " Discrete Customers".or if it say Product family it will hide all other sheets except sheets report builder and product family sheet.

    Thank you for your help.

  2. #2
    Valued Forum Contributor
    Join Date
    12-05-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010 & 2013
    Posts
    308

    Re: VBA to hide worksheets based on cell value

    Hi tantcu

    I think this does the job:

    Sub HideShts()
    Dim sht As Worksheet, strRpt As String
    
    strRpt = Sheets("Report Builder").Range("G1")
    
    For Each sht In ActiveWorkbook.Sheets
    If sht.Name = strRpt Or sht.Name = "Report Builder" Then
        sht.Visible = xlSheetVisible
        Else
        sht.Visible = xlSheetHidden
        End If
        Next sht
        
    End Sub
    Best regards, Rob.

  3. #3
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: VBA to hide worksheets based on cell value

    Thank you. It worked great!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Can I auto hide/unhide worksheets based on selected cell criteria.
    By cwashburn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-17-2013, 04:06 PM
  2. Rename and hide/unhide worksheets based on cell entry
    By whiteshadoz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-18-2013, 05:13 PM
  3. Hide columns in multiple worksheets based on one cell.
    By -Johan- in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-03-2011, 02:36 AM
  4. [SOLVED] Hide Worksheets based on value from Access DB
    By Mike G - D.C. in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-22-2006, 02:50 PM
  5. Replies: 3
    Last Post: 05-31-2006, 09:30 AM

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