Friends, I need your help to modify the macro
I need help to create Macro to Copy data from one sheet to another sheet if column headings match. In the below code when in the Headers column there is First Name column, it will copy the column from sheet 1 and paste the same under First Name column for sheet 2.
Please I need your help to modify the code and help me copy "Last name" and "country name" column data in the similar way from sheet 1 to sheet 2
Option Explicit
Sub Test()
Dim ched, phed, lr As Long
Sheets("Sheet1").Select
ched = Application.WorksheetFunction.Match("First Name", Sheets("Sheet1").RANGE("1:1"), False)
phed = Application.WorksheetFunction.Match("First Name", Sheets("Sheet2").RANGE("1:1"), False)
lr = Sheets("Sheet1").Cells(Rows.Count, ched).End(xlUp).Row
RANGE(Cells(2, ched), Cells(lr, ched)).Copy Sheets("Sheet2").Cells(2, phed)
Sheets("Sheet2").Select
RANGE(Cells(2, phed), Cells(Rows.Count, phed).End(xlUp)).NumberFormat = "DD/MM/YY"
End Sub
Bookmarks