For Loop Not Catching All Sheets

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • polyglot717
    New Member
    • May 2014
    • 2

    For Loop Not Catching All Sheets

    This code is meant to iterate over all of my sheets, but it is skipping some. Can anyone help me figure out why?

    Code:
    Sub BuildIntegration()
    
    'Setup Variables
        
        Dim NextRow As Integer
        Dim intSheet As Integer
        Dim WkshCount As Integer
        
        WkshCount = ActiveWorkbook.Worksheets.Count
            
    'Turn off screen refresh
        
        'Application.ScreenUpdating = False
    
    'Select first sheet of workbook
        
        Sheet1.Select
            
            
    'Unhide Cells
    
        For intSheet = 0 To WkshCount - 1
                
            intSheet = intSheet + 1
            Sheets(intSheet).Select
            Columns("K:X").Select
            Selection.EntireColumn.Hidden = False
            'MsgBox "continue..."
        Next intSheet
    Last edited by polyglot717; May 29 '14, 07:37 PM. Reason: Add code tags
  • Luk3r
    Contributor
    • Jan 2014
    • 300

    #2
    I don't think this line is necessary when doing a loop from zero to a count:

    Code:
    intSheet = intSheet + 1
    I assume that your program is actually skipping every other sheet.

    Comment

    • polyglot717
      New Member
      • May 2014
      • 2

      #3
      Thank you! After posting - I dug in deeper and realized that it was skipping every other. Then the fix was apparent. When I posted it seemed like it was random sheets.

      Comment

      • Luk3r
        Contributor
        • Jan 2014
        • 300

        #4
        Glad you got it figured out without me even though we landed on the same answer. :)

        Comment

        Working...