title: Vba code to retrieve an entire column from sheet1 if the value in a cell of sheet2 matches the value of a header in sheet1
body: <p>I'm trying to find vba code that will bring the contents of an entire column in "sheet1" to "sheet2" if the value in cell A1, matches one of the headers in "sheet1" below is what I have so far:</p>
  
  <pre><code>Sub searchdata()
  Dim lastrow As Long, x As Long
  
  lastcolumn = Sheets("Practice Associations").Cells(Columns.Count,.End(xlToRight)
  
  For y = 1 To lastcolumn
  If Sheets("Practice Associations").Cells(y, 1).Value = Sheets("Sheet2").Range("A1").Value Then
      Sheets("Sheet2").Range("A2:A1000").Value = Sheets("Sheet1").Column(x, 1).Value
  </code></pre>
  
  <p>Basically, I'm trying to build a dashboard that will pull a list of values if the value searched in a search box matches one of the headers in the table. Any help is appreciated! Thanks in advance.</p>