title: Dynamic column reference from heading identified in another Excel sheet
body: <p>Firstly I have to apologise as this is my first attempt at any VBA coding!</p>
  <p>I am trying to find a way of automating a process whereby I extract data from a single data sheet with multiple columns in it into several separate worksheets.</p>
  <p>My source data sheet has multiple column headings that are identified by their heading name, column number and column reference.</p>
  <p>I am looking for some code that will (for the 2 specified column headings in each of my output sheets:</p>
  <ul>
  <li>perform an auto filter selection (=Blanks for column 1 in the operation, &lt;&gt; Blanks for column 2 in the operation)</li>
  <li>copy and paste the returned data into a specified output sheet</li>
  <li>reset the auto filters in data sheet</li>
  <li>move onto the next output sheet, select the next two relevant columns identified in the next output sheet</li>
  <li>perform an auto filter selection (=Blanks for column 1 in the operation, &lt;&gt; Blanks for column 2 in the operation)</li>
  <li>copy and paste the returned data into a specified output sheet</li>
  <li>reset the auto filters in data sheet etc.</li>
  </ul>
  <p>I can do this for 1 sheet and repeat but fall over due to the data sheet columns not necessarily remaining in the same order (as new activity milestones are added between the activity I am counting are added).</p>
  <p>My crude code is below:</p>
  <pre class="lang-vb prettyprint-override"><code>Sub FcastSFR()
  '
  ' FcastSFR Macro
  '
  
  '
      Application.ScreenUpdating = False
  
      
      Range(&quot;A23:B345&quot;).Select
      Selection.ClearContents
      Sheets(&quot;MOAT&quot;).Select
      ActiveSheet.ShowAllData
      ActiveSheet.Range(&quot;$A$1:$DT$5000&quot;).AutoFilter Field:=17, Criteria1:=&quot;=&quot;
      ActiveSheet.Range(&quot;$A$1:$DT$5000&quot;).AutoFilter Field:=15, Criteria1:=&quot;&lt;&gt;&quot;
      Range(&quot;O1:P631&quot;).Select
      Application.CutCopyMode = False
      Selection.Copy
      Sheets(&quot;SFR Submit&quot;).Select
      Range(&quot;A23&quot;).Select
      Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
          :=False, Transpose:=False
  End Sub
  </code></pre>
  <p>I am looking for help to make the Field=17/Field=15 and the Range (&quot;O1:P631&quot;) be selected from the relevant output sheets.</p>
  <p>Help!!</p>