TropicalMagic
New Member
- Joined
- Jun 19, 2021
- Messages
- 47
- Office Version
- 365
- Platform
- Windows
Hi all,
I have 2 workbooks and would like to lookup row values using the common columns of Workbook 1's Column B and Workbook 2's Column F, match corresponding row values in Workbook 2's Column I, which is empty, to Workbook 1's Column Q.
The Index Match formula in Workbook2.Sheet(1).Columns("I:I")is given below:
INDEX(Workbook1.Sheet(1).Columns("Q:Q"), MATCH(Workbook2.Sheet(1).Columns("F:F"), Workbook1.Sheet(1).Columns("B:B"), 0))
However, since all columns have 10,000+ rows, the formula takes a long time to be applied by VBA.
Sample of Workbook 1's layout:
Sample of Workbook 2's layout:
*Note that the row values in Item_ID columns for Workbooks 1 and 2 may not be the same or sorted in order.
I tried using arrays to complete the task instead but am stuck, here is my code so far:
Can anyone help me out?
Many thanks!
I have 2 workbooks and would like to lookup row values using the common columns of Workbook 1's Column B and Workbook 2's Column F, match corresponding row values in Workbook 2's Column I, which is empty, to Workbook 1's Column Q.
The Index Match formula in Workbook2.Sheet(1).Columns("I:I")is given below:
INDEX(Workbook1.Sheet(1).Columns("Q:Q"), MATCH(Workbook2.Sheet(1).Columns("F:F"), Workbook1.Sheet(1).Columns("B:B"), 0))
However, since all columns have 10,000+ rows, the formula takes a long time to be applied by VBA.
Sample of Workbook 1's layout:
Sample of Workbook 2's layout:
*Note that the row values in Item_ID columns for Workbooks 1 and 2 may not be the same or sorted in order.
I tried using arrays to complete the task instead but am stuck, here is my code so far:
VBA Code:
Dim Lastrow1 As Long
Lastrow1 = Workbooks("Workbook1").Sheets(1).Cells(Rows.Count, "A").End(xlUp).Row
Dim Lastrow2 As Long
Lastrow2 = Workbooks("Workbook2").Sheets(1).Cells(Rows.Count, "A").End(xlUp).Row
InArray = Workbooks("UPS Carry Clear Brokerage Bid Activity.xlsx").Sheets(1).Range(Cells(1, 9), Cells(LASTROW1, 9))
Searchfor = Workbooks("Panorama Data.xlsx").Sheets(1).Range(Cells(2, 17), Cells(LASTROW2, 17))
Dim i As Long
For i = 1 To LASTROW2
If InArray(i, 17) = Searchfor Then
Workbooks("UPS Carry Clear Brokerage Bid Activity.xlsx").Sheets(1).Range(Cells(1, 9), Cells(LASTROW1, 9)) = InArray(i, 17)
Exit For
End If
Next i
Can anyone help me out?
Many thanks!