Search for Column headers and copy headers to destination sheet
<p>I need a small help here,The header Names are the yellow highlighted row, now if you see the Mastersheet the Address is in C column, if new data comes up then the Address Column might be in D column, hence I want someone to help me to tweak the code which can search for the header names and copy to Destination sheet , I want only selected headers to be copied not the entire column or the entire header row for example only StudentName,StudentID and Section to be copied to the destination sheet</p>

<p>Any Help would be appreciated.</p>

<pre><code>    Sub test5()
    Dim Headers As Variant
    Dim i As Long
    Dim SourceColumn As Range
    Dim DestinationSheet As Worksheet

    Set DestinationSheet = ThisWorkbook.Sheets("destination")
    Headers = Array("StudentName", "StudentID", "Address")

    For i = LBound(Headers) To UBound(Headers)
        With ThisWorkbook.Sheets("Mastersheet").Rows(1)
            Set SourceColumn = .Find(Headers(i), after:=.Cells(1, 1), MatchCase:=False)
        End With

        If Not SourceColumn Is Nothing Then
            Headers.Copy Destination:=DestinationSheet.Range("A4:G3")
        End If
    Next i

End Sub
</code></pre>

<p><a href="https://i.stack.imgur.com/7TXiA.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7TXiA.jpg" alt="The yellow highlighted Names are the headers"></a></p>

<p><a href="https://i.stack.imgur.com/B5XsP.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/B5XsP.jpg" alt="Destination Sheet"></a></p>