Referencing table in another workbook

jwburritt

New Member
Joined
May 22, 2019
Messages
49
Office Version
  1. 365
Platform
  1. Windows
Hello: I have a formula in a CurrentSheet that is looping through data looking at the headers of a data table (data_table) in the same workbook for index and match. That code works fine and is below. However, I need to make it refer to another data table in another workbook for the data. That table is named the same and has the same header structure. I've tried a ton of different ideas to make the reference work, but so far no luck.

Any help would be appreciated!

Code:
For i = 1 To 7    
    With Cells(i, 7)
                .Formula = "=INDEX(data_table[Account Type],MATCH(CurrentSheet!" & Cells(i, 6).Address(0, 0) & ",data_table[Account],0))"
                .Value = .Value
    End With
                
    Next i
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Maybe this (untested):
Code:
[COLOR=#ff0000]SrcName = "Other Workbook.xlsx"[/COLOR]
For i = 1 To 7
    With Cells(i, 7)
        .Formula = "=INDEX([COLOR=#ff0000]'" & SrcName & "'![/COLOR]data_table[Account Type],MATCH(CurrentSheet!" & Cells(i, 6).Address(0, 0) & ",[COLOR=#ff0000]'" & SrcName & "'![/COLOR]data_table[Account],0))"
        .Value = .Value
    End With
Next i
 
Upvote 0
Solution
The suggested solution has now been tested to work as posted.
Note: the "Other Workbook" should be opened in the same instance of Excel.
 
Upvote 0
Thanks again. This syntax ended up working...

Code:
.Formula = "=INDEX('[Other Workbook.xlsm]Data'!data_table[Account Type],MATCH(CurrentSheet!" & Cells(i, 6) _
                    .Address(0, 0) & ",'[Other Workbook.xlsm]Data'!data_table[Account],0))"
 
Upvote 0

Forum statistics

Threads
1,214,795
Messages
6,121,624
Members
449,041
Latest member
Postman24

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top