One way
Option Explicit
Sub AddData()
Dim rID As Range, rIDwithoutRow1 As Range, rRow As Range
With ActiveWorkbook.Worksheets("Main")
'remove duplicate ID's from Main
.Cells(1, 1).CurrentRegion.RemoveDuplicates Columns:=1, Header:=xlYes
'.CurrentRegion selects everything around (1,1) or A1
Set rID = .Cells(1, 1).CurrentRegion
'.Resize this way gives rows 2 to last one
Set rIDwithoutRow1 = rID.Cells(2, 1).Resize(rID.Rows.Count - 1, rID.Columns.Count)
'sort by ID
With .Sort
.SortFields.Clear
.SortFields.Add Key:=Range("A1"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortTextAsNumbers
.SetRange rIDwithoutRow1
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End With
'go down through the data rows
For Each rRow In rIDwithoutRow1.Rows
With rRow
'continue if not found
On Error Resume Next
.Cells(3).Value = Application.WorksheetFunction.VLookup(.Cells(1).Value, Worksheets("Interests").Cells(1, 1).CurrentRegion, 2, False)
.Cells(4).Value = Application.WorksheetFunction.VLookup(.Cells(1).Value, Worksheets("Activities").Cells(1, 1).CurrentRegion, 2, False)
.Cells(5).Value = Application.WorksheetFunction.VLookup(.Cells(1).Value, Worksheets("Languages").Cells(1, 1).CurrentRegion, 2, False)
On Error GoTo 0
End With
Next
End Sub
Paul