Ok this is the code to make it loop and search for the correct column name
Hope this helps and does what you need.... and like you said, if someone else wants to help. go ahead.vb Code:
Sub Copy() Dim i As Integer, x As Long, z As Long Dim Source As Workbook Dim LastRow As Long Dim OriginalWorkBook As Workbook Set OriginalWorkBook = ThisWorkbook Const MyDir As String = "C:\Users\Shadow\Desktop\file a&b\" Set Source = Workbooks.Open(MyDir & "file b.xlsx") Application.ScreenUpdating = False For x = 1 To 5 Source.Sheets("Tabelle1").Activate For z = 1 To 5 If OriginalWorkBook.Worksheets("Tabelle1").Cells(1, x) = Source.Worksheets("Tabelle1").Cells(1, z) Then LastRow = Source.Worksheets("Tabelle1").Cells(Rows.Count, z).End(xlUp).Row Source.Worksheets("Tabelle1").Range(Cells(2, z), Cells(LastRow, z)).Select Selection.Copy OriginalWorkBook.Activate i = OriginalWorkBook.Worksheets("Tabelle1").Cells(Rows.Count, x).End(xlUp).Row OriginalWorkBook.Worksheets("Tabelle1").Cells(i + 1, x).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False End If Next z z = 0 Next x Application.ScreenUpdating = True End Sub




