title: Apply dynamic AutoFilter across worksheets based on filter on 1st sheet
body: <p>I am trying to create a dynamic autofilter in excel which could be applied across all the sheets (total: 5) in the excel based on what filter the user selects in 1st sheet.</p>
  
  <p>For Example: I have 5 sheets in an excel all with different columns and 1 "primary key" column.
  Sheet1 = Headers - PK, Col1, Col2 ...
  Sheet2 = Headers - PK, Col6, Col7 ...
  .
  .
  Sheet5 = Headers - PK, Col20, Col21 ...</p>
  
  <p>The filter should work like, the user creates a filter on the column headers on sheet1 via selecting the header and then Home > Sort &amp; Filter. Once we have filters on header, the user can then selects multiple values (check boxes) on the 1st column (PK) and now wants that filter to be applied across all sheets on the PK column.</p>
  
  <p>I was able to create an autofilter but it is actually static and does not change based on user input.</p>
  
  <p>Version: MS OFfice Excel 2010</p>
  
  <p><strong>VB Macro:</strong></p>
  
  <pre><code>Sub apply_autofilter_across_worksheets()
  Dim xWs As Worksheet
  On Error Resume Next
  For Each xWs In Worksheets
      xWs.Range("A1").AutoFilter 1, "=Sheet1!$A$1"
  Next
  End Sub
  </code></pre>
  
  <p>I am relatively new to excel. In this case, the column I am filtering on, on the first sheet is a number, so the array I am trying to use in the criteria seems to be a text.</p>