title: Running macros on Hidden Sheets
body: <p>I have a main sheet called "JE". This sheet is the main form of my workbook. There are many sheets that are called and referenced in macros. I would like to hide all of these sheets so <strong>just</strong> the main form/sheet appears. But, for example, on the main sheet I have a button that, once clicked, triggers a macro which takes the user to a separate sheet of listed values. On the main form/sheet, I have written a sub to hide all of the sheets but once I saved the code, it didn't hide all of the sheets. I've seen other questions that are somewhat similar to mine but, I've never had to do something like this before and I'm unsure of how to incorporate those answers to my workbook, if I even can.</p>
  
  <p>I also tried to write some code to unhide the sheets the macros are touching but that hasn't worked so far. </p>
  
  <p>Here is the sub I tried implementing on the main sheet:</p>
  
  <pre><code>Sub HideSheets()
  
  Dim ws As Worksheet
  
  For Each ws In ThisWorkbook.Sheets
  If ws.Name &lt;&gt; "JE" Then
      ws.Visible = xlSheetHidden
  End If
  Next
  End Sub
  </code></pre>
  
  <p>Here is the code I tried adding to the macro that is connected to the button I mentioned earlier:</p>
  
  <pre><code>   Sub acct_search()
  '
  ' acct_search Macro
  '
  
  '
  Application.ScreenUpdating = False
  Sheets("acct_codes").Visible = True
  
      Sheets("acct_codes").Select
  
  
  End Sub
  </code></pre>
  
  <p>it works as it normally should but doesn't stay hidden. I'd like it to only be visible when called upon by that macro and once the user leaves the sheet that has all of the accounts, I'd like the sheet to go back to being hidden.</p>
  
  <p>Could I write a sub in each sheet I want to hide that looks something like:</p>
  
  <pre><code>Sub HideSheet()
  
      Dim sheet As Worksheet
  
      Set sheet = ActiveSheet 'Or set sheet = SheetName
  
      sheet.Visible = xlSheetVeryHidden
  
  End Sub
  </code></pre>