Sub Import()
Dim fname As String
Dim Erng As Range, aCell As Range, bCell As Range
Dim Crng As Range, Frng As Range, Irng As Range
With ActiveSheet
Set Crng = .Range("C7", .Cells(.Rows.Count, 3).End(xlUp))
Set Frng = .Range("F7", .Cells(.Rows.Count, 6).End(xlUp))
Set Irng = .Range("I7", .Cells(.Rows.Count, 9).End(xlUp))
fname = ActiveSheet.Name
End With
Workbooks.Open FileName:=Range("M2")
Sheets(fname).Select
With ActiveSheet
Set Erng = .Range("E5", .Cells(.Rows.Count, 5).End(xlUp))
End With
For Each aCell In Crng
Set bCell = Erng.Find(What:=aCell, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
If Not bCell Is Nothing Then
aCell.Offset(, -1) = bCell.Offset(, -1)
aCell.Offset(, 1) = bCell.Offset(, -2)
End If
Next
For Each aCell In Frng
Set bCell = Erng.Find(What:=aCell, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
If Not bCell Is Nothing Then
aCell.Offset(, -1) = bCell.Offset(, -1)
aCell.Offset(, 1) = bCell.Offset(, -2)
End If
Next
For Each aCell In Irng
Set bCell = Erng.Find(What:=aCell, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
If Not bCell Is Nothing Then
aCell.Offset(, -1) = bCell.Offset(, -1)
aCell.Offset(, 1) = bCell.Offset(, -2)
End If
Next
ActiveWindow.Close
End Sub
Bookmarks