Trying to INDIRECT XLOOKUP in closed workbooks. Looking for a VBA solution

xcfalcon351

New Member
Joined
Aug 31, 2022
Messages
3
Office Version
  1. 2021
Platform
  1. Windows
Hi All. I really need some help.
I have a number of workbooks as records and need to generate a master register.

The records are in the following format;
R1002.xlsx
AB
5ItemDetails
6CategoryDownline
7Unit DescriptionTwo Hose Umbilical Reeler 480m
8Fluid Type
9Max Pressure5,000 psi
10Unit ManufacturerTrident Australia
11Unit Manufacturer Part No.
12Unit Serial No.TS1010
13Pump 1 Part No.
14Pump 1 Serial No.
15Pump 1 Manufacturer
16Pump 1 Pressure Ratio
17Pump 1 Max Pressure
18Pump 1 Flow Rate (L/min)
19Pump 1 Last Re-Kit Date
20Pump 2 Part No.
21Pump 2 Serial No.
22Pump 2 Manufacturer
23Pump 2 Pressure Ratio
24Pump 2 Max Pressure
25Pump 2 Flow Rate (L/min)
26Pump 2 Last Re-Kit Date
27Flushing Pump Part No.
28Flushing Pump Serial No.
29Flushing Pump Manufacturer
30Flushing Pump Flow Rate (L/min)
31Flushing Pump Max Pressure
32Flushing Pump Last Re-Kit Date
33Circulation Pump Manufacturer
34Circulation Pump Part No.
35Circulation Pump Serial No.
36Circulation Pump Flow Rate (L/min)
37Circulation Pump Last Re-Kit Date
38Pressure Filter Part No.
39Return Filter Part No.
Unit Details


My Master Register looks like;
Master Register.xlsm
ABCDEFGHIJ
6UnitCategoryUnit DescriptionFluid TypeHydraulic Seal MaterialMax PressureUnit Manufacturer Part No.Unit Serial No.Unit ManufacturerDaily Rate
8R1002Gas BoosterSC GBT 30/75 in stainless steel frameGas15,000 psiNoneSC Hydraulics$150
9R1003Pressure Test Unit101 series SC pump 195:1 8 litre tank20,000 psi1016Trident Australia$100
10R1005Chart RecorderDual Pen Chart Recorder6,000 psi / 15,000 psi04.02919.1-01DE WIT$40
11R1009Pressure Test UnitPump10,000 psi474-212Haskel
12R1011Pressure Test Unit101 series SC pump 70:1 8 litre tank7,000 psi405036Staffordshire Hydraulics$100
13R1012Pressure Test Unit101 series SC pump 280: No Tank28,000 psi1030Trident Australia$100
Equipment List


Column 'A' of the Master Register contains the name of each individual record as well as a hyperlink to the file.

I am currently using the formula;

=LET(x, XLOOKUP(B$6, INDIRECT("'["&$A8&".xlsx]Unit Details'!$A$6:$A$156"), INDIRECT("'["&$A8&".xlsx]Unit Details'!$B$6:$B$156"), 0, 1), IF(x="", "", x))

filled from B8 to J8 of the Master Register to find the column heading in the target record and return the corresponding information to the master register, however this obviously only works when the target record is open.

The intention was that this single formula could be used across the entire master register, and if additional fields from the record were required in the future, adding the column with a correct heading would integrate the additional information without changing the formula.

There are approximately 1000 individual records so I don't think opening each record one by one every time the Master Register is opened is feasible. I need to be able to look into a closed workbook. I also need this action to happen automatically when the Master Register is opened.

VBA is new to me and so far I have been unsuccessful in writing code to make this work.
I did find this code that supposedly did what I needed, but I couldn't work out how to make it work on an array.

VBA Code:
Public Function GetValueFromClosedWorkbook(FileName As String, Sheet As String, CellAddress As String)
'?GetValueFromClosedWorkbook("C:\temp\excel partners.xlsx", "Excel", "B2")
Dim strFilePath As String, strFileNameShort As String, strArg As String
    strFilePath = Left(FileName, InStrRev(FileName, "\"))
    strFileNameShort = Right(FileName, Len(FileName) - InStrRev(FileName, "\"))
    strArg = "'" & strFilePath & "[" & strFileNameShort & "]" & Sheet & "'!" & _
          Range(CellAddress).Range("A1").Address(, , xlR1C1)
    GetValueFromClosedWorkbook = ExecuteExcel4Macro(strArg)
End Function

If anyone would take the time to assist me I would be deeply grateful and am happy to provide any additional information.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Does anyone know of a paid resource for commissioning a script such as I am requesting above?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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