Sub VLOOKUP1()
Application.ScreenUpdating = False
Workbooks("excel1.xlsx").Activate
Sheets(1).Activate
'insert two cloumns
Range("b:b").Insert shift:=xlShiftToRight
Range("b:b").Insert shift:=xlShiftToRight
Range("A1").Select 'set the begin range as your choice
While ActiveCell <> ""
Application.StatusBar = ActiveCell.Row & " " & AvtiveCell
SName = ActiveCell
SMatch = owner1(SName)
If SMatch <> "" Then
ActiveCell.Offset(0, 1) = SMatch
End If
ActiveCell.Offset(1, 0).Select
Wend
Application.StatusBar = False
Range("A1").Select 'set the begin range as your choice
While ActiveCell <> ""
Application.StatusBar = ActiveCell.Row & " " & AvtiveCell
SName = ActiveCell
SMatch = issue1(SName)
If SMatch <> "" Then
ActiveCell.Offset(0, 2) = SMatch
End If
ActiveCell.Offset(1, 0).Select
Wend
Application.StatusBar = False
' For sheet2 vlookups
Workbooks("excel1.xlsx").Activate
Sheets(2).Activate
'insert two cloumns
Range("b:b").Insert shift:=xlShiftToRight
Range("b:b").Insert shift:=xlShiftToRight
Range("A1").Select 'set the begin range as your choice
While ActiveCell <> ""
Application.StatusBar = ActiveCell.Row & " " & AvtiveCell
SName = ActiveCell
SMatch = owner2(SName)
If SMatch <> "" Then
ActiveCell.Offset(0, 1) = SMatch
End If
ActiveCell.Offset(1, 0).Select
Wend
Application.StatusBar = False
Range("A1").Select 'set the begin range as your choice
While ActiveCell <> ""
Application.StatusBar = ActiveCell.Row & " " & AvtiveCell
SName = ActiveCell
SMatch = issue2(SName)
If SMatch <> "" Then
ActiveCell.Offset(0, 2) = SMatch
End If
ActiveCell.Offset(1, 0).Select
Wend
Application.StatusBar = False
End Sub
Function owner1(srch) As String
Set c = Workbooks("excel2.xlsx").Sheets(1).Columns("A").Find(srch, LookIn:=xlValues, LookAt:=xlWhole)
If Not c Is Nothing Then
owner1 = c.Offset(0, 1) 'Value of column Q in the same row
Else
owner1 = "NA"
End If
End Function
Function issue1(srch) As String
Set c = Workbooks("excel2.xlsx").Sheets(1).Columns("A").Find(srch, LookIn:=xlValues, LookAt:=xlWhole)
If Not c Is Nothing Then
issue1 = c.Offset(0, 2) 'Value of column Q in the same row
Else
issue1 = "NA"
End If
End Function
Function owner2(srch) As String
Set c = Workbooks("excel2.xlsx").Sheets(1).Columns("A").Find(srch, LookIn:=xlValues, LookAt:=xlWhole)
If Not c Is Nothing Then
owner2 = c.Offset(0, 1) 'Value of column Q in the same row
Else
owner2 = "NA"
End If
End Function
Function issue2(srch) As String
Set c = Workbooks("excel2.xlsx").Sheets(1).Columns("A").Find(srch, LookIn:=xlValues, LookAt:=xlWhole)
If Not c Is Nothing Then
issue2 = c.Offset(0, 2) 'Value of column Q in the same row
Else
issue2 = "NA"
End If
End Function