Consulting

Results 1 to 4 of 4

Thread: Skip first sheet in For Each loop?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Skip first sheet in For Each loop?

    I was trying to freeze the first row of each sheet besides the first sheet. Can someone help me find a way to skip the first sheet in this loop?


    Public Sub FreezePanes()
        
        Dim s As Worksheet
        Dim c As Worksheet
        
         '// store current sheet
        Set c = ActiveSheet
        
         '// Stop flickering...
        Application.ScreenUpdating = False
        
         '// Loop throught the sheets
        For Each s In ThisWorkbook.Worksheets
            
             '// Have to activate - SplitColumn and SplitRow are properties
             '// of ActiveSheet
            s.Activate
            
            With ActiveWindow
                .SplitColumn = 0
                .SplitRow = 1
                .FreezePanes = True
            End With
            
        Next
        
         '// Back to original sheet
        c.Activate
        Application.ScreenUpdating = True
        
        Set s = Nothing
        Set c = Nothing
        
    End Sub
    Last edited by SamT; 06-09-2016 at 11:27 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •