I want to copy data from specific column in Sheet 1 to a specific column in Sheet 2. There are 20 such columns and that mapping is maintained in a table like
I have written the code to search column name (source and destination sheets) from but am unable to copy the data from source column (dynamic range) to destination column.
Sub search_validate()
Dim j As Integer
Dim sourcSearch, destSearch As String
Dim sCell, dCell As Range
For j = 3 To 20
sourcSearch = Sheet6.Range("Z" & j).Value ' pickup selected source column name
destSearch = Sheet6.Range("AA" & j).Value ' pickup selected destination column name
Set sCell = Sheet1.Rows(2).Find(What:=sourcSearch, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
Set dCell = Sheet2.Rows(2).Find(What:=destSearch, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
' sCell.Address or sCell.Column to get source column header address but data starts after this column. dynamic range
' dCell.Address or dCell.Column to get destination column header address. no data in destination column except header.
Next j
End Sub