Sub test()
Dim ws As Worksheet
Dim i As Integer
Dim fRange As Range
'Perform search for Sheet1
Set ws = Sheets("Sheet1")
i = 3
While i <= ActiveWorkbook.Sheets.Count
ws.Select
Set fRange = Range("A1")
fRange.Select
While fRange.Value <> ""
Sheets(i).Select
Range("A1").Select
While ActiveCell.Value <> ""
If ActiveCell.Value = fRange.Value Then
fRange.Offset(0, 1).Value = Sheets(i).Name
ActiveCell.Offset(1, 0).Select
Else
ActiveCell.Offset(1, 0).Select
End If
Wend
Set fRange = fRange.Offset(1, 0)
Wend
i = i + 1
Wend
'Perform search for Sheet2
Set ws = Sheets("Sheet2")
i = 3
While i <= ActiveWorkbook.Sheets.Count
ws.Select
Set fRange = Range("A1")
fRange.Select
While fRange.Value <> ""
Sheets(i).Select
Range("A1").Select
While ActiveCell.Value <> ""
If ActiveCell.Value = fRange.Value Then
fRange.Offset(0, 1).Value = Sheets(i).Name
ActiveCell.Offset(1, 0).Select
Else
ActiveCell.Offset(1, 0).Select
End If
Wend
Set fRange = fRange.Offset(1, 0)
Wend
i = i + 1
Wend
End Sub