Вы можете попробовать что-то вроде этого.
Вы заполняете массив номерами элементов и именами листов.
Sub CompareCopy()
Dim FirstSheet As Worksheet
Set FirstSheet = ActiveWorkbook.Worksheets("Sheet1") 'Define data sheet
Dim SecondSheet As Worksheet
Set SecondSheet = ActiveWorkbook.Worksheets("Sheet2") 'Define sheet to paste into
Dim lcol As Long
Dim lrow As Long
Dim lrowCompare As Long
Dim Val As String
Dim i As Long
Dim j As Long
Dim arr() 'Define the array
arr() = Array(1, 12, 13, 32, 42, 48, 162, 178, 216, 316, 321, 789, 987, 995, 996, 997, 999) 'Set the array with all the item numbers you want to compare
lcol = FirstSheet.Cells(5, Columns.Count).End(xlToLeft).Column 'Find last column in Row 5
lrow = FirstSheet.Cells(Rows.Count, 2).End(xlUp).Row 'Find last row in Sheet1, for column B
lrowCompare = SecondSheet.Cells(Rows.Count, 2).End(xlUp).Row 'Find last row in Sheet2 for Column B
For k = 4 To lcol 'Loop from Column D to last Column
For i = 11 To lrow 'Loop through ID column in Sheet 1
Val = FirstSheet.Cells(i, 2).Value 'Get Item Value in Sheet 1
For Each arrayItem In arr 'Loop through each element in Array
If arrayItem = Val Then 'If array item is equal to Val then
SecondSheet.Cells(lrowCompare, 3).Value = arrayItem 'Print array item
SecondSheet.Cells(lrowCompare, 1).Value = FirstSheet.Cells(5, k).Value 'Print number
SecondSheet.Cells(lrowCompare, 2).Value = FirstSheet.Cells(6, k).Value 'Print name
If FirstSheet.Cells(i, k).Value <> "" Then 'If cell value is blank then ignore otherwise copy value
SecondSheet.Cells(lrowCompare, 4).Value = FirstSheet.Cells(i, k).Value 'Copy value
End If
lrowCompare = lrowCompare + 1 'Add 1 to row
End If
Next arrayItem
Next i
Next k
End Sub