title: Issue re-applying a filter on workbook close
body: <p>I have the following code in the ThisWorkbook section:</p>
  
  <pre><code>Private Sub Workbook_BeforeClose(Cancel As Boolean)
      Sheet("Sheet2").AutoFilter.ApplyFilter
      ActiveWorkbook.Save
      ThisWorkbook.Saved = True
  End Sub
  </code></pre>
  
  <p>I assumed the second line would re-apply the filter I have set in the AutoFilter on Sheet 2. </p>
  
  <p>I have data feeding in to Sheet 1, and Sheet 2 reads that data and filters it. The document is then working with AutoHotkey to: open, take more data, save and close on a timer. I just need it so that when the document closes it looks at that filter on Sheet2 and re-applies it. </p>
  
  <p>I have tried:</p>
  
  <pre><code>Private Sub Workbook_BeforeClose(Cancel As Boolean)
      Sheet2.AutoFilter.ApplyFilter
      ActiveWorkbook.Save
      ThisWorkbook.Saved = True
  End Sub
  </code></pre>
  
  <p>But that did not work. After looking through some VBA stuff, it seemed changing <code>Sheet2.AutoFilter.ApplyFilter</code> to <code>Sheet("Sheet2").AutoFilter.Applyfilter</code> would do the trick. But now I just get <em>Compile Error: sub or function not defined</em>.</p>