title: VBA - Copy column values from multiple sheets based on column headings.
body: <p>I'm still new to VBA and I'm a bit lost on how to solve this particular issue.</p>
  
  <p>I have several worksheets within 1 workbook. The goal is to copy data from each worksheet based on the column headings, since not all of the column headings are uniform across all sheets. </p>
  
  <p>For ex:</p>
  
  <p>The Master Sheet has 6 column headings which I'd like to pull. </p>
  
  <p>Sheet 1 has 8 column headings, the values for some columns within this are blank. </p>
  
  <p>Sheet 2 has 7 column headings. </p>
  
  <p>Sheet 3 has 10 column headings, etc. </p>
  
  <p>My goal is to go to each sheet, have it loop through each column heading and copy/paste the data into the Master sheet if the column heading matches. </p>
  
  <p>I don't know how to get it to look for the last row and copy the whole column based on the heading. </p>
  
  <p>An example of code I've pieced together below:</p>
  
  <pre><code>Sub MasterCombine()
  
  Worksheets("Master").Activate
  
  Dim ws As Worksheet
  Set TH = Range("A1:F1")
  
  For Each ws In ActiveWorkbook.Worksheets
  
      If ws.Name &lt;&gt; "Master" And ws.Range("A8").Value &lt;&gt; "" Then
      ws.Select
  
      Range("A8").Select
      Range(Selection, Selection.End(xlToRight)).Select
      Range(Selection, Selection.End(xlDown)).Select
      Selection.Copy
      Worksheets("Master").Activate
  
  
  
  For Each cell In TH
  
  If cell.Value = "Subject" Then
  
  cell.EntireColumn.Copy
  
  
  End If
  </code></pre>
  
  <p>The problem with the above is that it copies the entire range but doesn't filter out column headings that aren't in the Master sheet. </p>
  
  <p>Any help would be appreciated.</p>