I'm using OFFSET/INDIRECT to pull an array from multiple workbooks. Their formats are similar to one another so I want to use one formula for all, with OFFSET/INDIRECT.
Here's what I have so far in A2:
=OFFSET(INDIRECT("'"&A1&"'!$A$1"),MATCH("Total",INDIRECT("'"&A1&"'!$A:$A"),0),0,2,3)
With A1 being the name of the source workbook - e.g.: My Workbook.xlsx. Then in A4 I have the name of a different source workbook and just copy the formula down to A5 to be:
=OFFSET(INDIRECT("'"&A4&"'!$A$1"),MATCH("Total",INDIRECT("'"&A4&"'!$A:$A"),0),0,2,3)
And so on. However, I have maybe 50 workbooks I need to pull data from, and having all 50 open whenever I need to look at the data isn't ideal. I tried making a simple macro that open all 50 workbooks at once, but I still end up having to close them afterwards and it's tedious.
I tried using the VBA solution from here and here. The new formula looks like this:
=OFFSET(INDIRECTVBA("'"&A1&"'!$A$1"),MATCH("Total",INDIRECTVBA("'"&A1&"'!$A:$A"),0),0,2,3)
And I got a #VALUE! error. How do I fix this? Here's what in VBA:
Public Function INDIRECTVBA(ref_text As String)
INDIRECTVBA = Application.ThisCell.Parent.Range(ref_text)
End Function
Public Sub FullCalc()
Application.CalculateFull
End Sub
I'm aware that even if I get this fixed, I still have OFFSET function which also requires the source workbook to be open. What's the alternative to this OFFSET/INDIRECT setup that won't require me to open all the sourcebooks?
Please let me know if there's any confusion.
A Worksheet Change: Excel
INDIRECTVBA AlternativeA1, A4, A7,... etc., and when values change in the source workbooks.Sheet Module e.g.
Sheet1.xlsm(.xlsb).View Code.Sheet1but it could be different in your case.ThisWorkbookModuleThisWorkbook.Sheet1).ThisWorkbookModule), paste the following code.Standard Module e.g.
Module1Insert Module.Set dws = Sheet1 ' the sheet's code name ' *****and replaceSheet1with the memorized sheet code name (note that there are no quotes).