+ Reply to Thread
Results 1 to 3 of 3

Apply a hide/unhide macro to all selected tabs

Hybrid View

  1. #1
    Registered User
    Join Date
    10-21-2014
    Location
    Belgium
    MS-Off Ver
    MS office 2013
    Posts
    3

    Apply a hide/unhide macro to all selected tabs

    Hi,

    I would like to use the code of that thread( http://www.excelforum.com/excel-prog...ding-rows.html)

    BUT is there a way to apply the below code to all selected tabs


    Thank you


    The code is ( thanks to Colin Legg)

        
        Dim rngCell As Range, rngToHide As Range, rngToCheck As Range
        Dim xlCalc As XlCalculation
        
        Application.ScreenUpdating = False
        xlCalc = Application.Calculation
        Application.Calculation = xlCalculationManual
        
        Set rngToCheck = ActiveSheet.Range("B2:B81")
        
        For Each rngCell In rngToCheck.Cells
            If rngCell.Value = " " Or rngCell.Value = 0 Then
                If rngToHide Is Nothing Then
                    Set rngToHide = rngCell
                Else
                    Set rngToHide = Union(rngToHide, rngCell)
                End If
            End If
        Next rngCell
         
        rngToCheck.Parent.Unprotect
        rngToCheck.EntireRow.Hidden = False
        
        If Not rngToHide Is Nothing Then
            rngToHide.EntireRow.Hidden = True
        End If
        
        rngToCheck.Parent.Protect
        Application.Calculation = xlCalc
        Application.ScreenUpdating = True
    
    End Sub
    
    Sub UnHideRows()
        
        Dim xlCalc As XlCalculation
        
        Application.ScreenUpdating = False
        xlCalc = Application.Calculation
        Application.Calculation = xlCalculationManual
        
        ActiveSheet.Unprotect
        ActiveSheet.Range("B2:B81").EntireRow.Hidden = False
        ActiveSheet.Protect
        
        Application.Calculation = xlCalc
        Application.ScreenUpdating = True
    
    End Sub

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Apply a hide/unhide macro to all selected tabs

    Your UnhideRows sub as an example...
    Sub UnHideRows()
        
       Dim xlCalc As XlCalculation
       Dim ws As Excel.Worksheet
        
       Application.ScreenUpdating = False
       xlCalc = Application.Calculation
       Application.Calculation = xlCalculationManual
        
       For Each ws In ThisWorkbook.Windows(1).SelectedSheets
        
          With ws
             .Unprotect
             .Range("B2:B81").EntireRow.Hidden = False
             .Protect
          End With
       Next
        
       Application.Calculation = xlCalc
       Application.ScreenUpdating = True
    
    End Sub

  3. #3
    Registered User
    Join Date
    10-21-2014
    Location
    Belgium
    MS-Off Ver
    MS office 2013
    Posts
    3

    Re: Apply a hide/unhide macro to all selected tabs

    Thank you but I am more interested in the Hide macro, I should miss somthing, but it doesn't work.

+ 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. [SOLVED] Now you see it, now you don't - Use XML to hide/unhide standard Ribbon tabs?
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-24-2013, 12:05 PM
  2. [SOLVED] How to add macro to button to hide or unhide if box is selected?
    By jgomez in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-16-2012, 10:17 AM
  3. Using checkboxes on summary sheet to name tabs and hide/unhide tabs
    By eew2201 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-11-2012, 06:13 PM
  4. Hide/unhide Tabs by color
    By angeljdiez in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-13-2012, 03:11 AM
  5. Hide/Unhide Tabs VBA
    By JIBG in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-20-2007, 03:08 AM

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