title: VBA: Excel loop - hiding/unhiding sheets
body: <pre><code>Sub Hideall_butlast_10()
  Dim ws As Worksheet
  For Each ws In ActiveWorkbook.Worksheets
  ws.Visible = xlSheetVisible
  Next ws
  
  i = Worksheets.Count
  For x = 10 To i
      Sheets(x).Select
      ActiveSheet.Visible = xlSheetHidden
  Next x
  End Sub
  </code></pre>
  
  <p>Hey guys</p>
  
  <p>I am trying to edit my code above to unhide all the sheets then hide all the sheets EXCEPT the first 5 and the last 10 (The 10 will change) - But the first 5 are always showing </p>
  
  <p>My workbook has between 50-300 pages (changes daily)</p>
  
  <p>Hope someone can point me in the right direction</p>
  
  <p>Thanks</p>