Forum Discussion
hrh_dash
May 26, 2022Iron Contributor
How do i create a vba code for a index match with 2 different workbooks without opening the workbook
I would like to create an iferror index match VBA code by taking reference from 2 different workbooks; export and clRequest. The first index match would be looking up from export workbook. If the...
- May 30, 2022
Does this work?
Sub Index_Match() Dim ws As Worksheet 'current sheet Dim exportWb As Workbook Dim clRequestWb As Workbook Dim v As Variant Set clRequestWb = ThisWorkbook Set ws = clRequestWb.Worksheets("Sheet1") Set exportWb = Workbooks.Open("C:\Users\hrhquek\desktop\export.xlsx") v = Application.Match(ws.Cells(15, 3), exportWb.Sheets("Sheet1").Range("E:E"), 0) If IsError(v) Then v = Application.Match(ws.Cells(15, 3), clRequestWb.Sheets("No SAP ID").Range("B:B"), 0) If IsError(v) Then MsgBox "Credit Limit is not allocated to this customer" Else ws.Cells(14, 3).Value = Application.Index(clRequestWb.Sheets("No SAP ID").Range("A:A"), v) End If Else ws.Cells(14, 3).Value = Application.Index(exportWb.Sheets("Sheet1").Range("B:B"), v) End If End Sub
hrh_dash
May 30, 2022Iron Contributor
Hi HansVogelaar , would you be able to assist on this?