Excel cell reference from closed workbook using file name in cell

Allan

I have a central location that contains 96 xls files; each of these 96 files represent an individual test located here:

"\server5\Operations\MainBoard testing central location DO NOT REMOVE or RENAME"

I created an Excel workbook to input all the information of each individual test on to a single sheet. Then, I used a VBA to pull the names of the files and add a link to the file on a second sheet on the same workbook. I linked those files to sheet 1.

Next, I added all the information on the top row corresponding to the test performed broken down in to a single line per workbook (Test).

Now I need to populate sheet 1 on the new workbook (Advanced Main board test log.xlsx)

So far this formula works, but only for open workbooks:

=INDIRECT("'\\server5\Operations\MainBoard testing central location DO NOT REMOVE or RENAME\["&A7&"]Summary'!$E9")

Where A7 represents the column of filenames which ranges from A6 to A103

Summary E9 is the cell I would like to enter in cell C7

Excel capture of C7

Please note the populated values, this is because I have those 2 work books open, All #REF! cells contain the same formula as the populated cells.

please let me know if you need any additional information to accomplish this tedious task

I also tried doing Microsoft recommended method:

='[20160613 1002257 35000010-01B.xls]Summary'!$E9

replaced file name with cell containing file name:

='["&A7&"]Summary'!$E9

and I get #REF! in the cell and formula bar automatically changes to:

='(\\server5\Operations\MainBoard testing central location DO NOT REMOVE or RENAME\["&A7&"]Summary'!$E9
Kevin

According to Microsoft, the Indirect() function must have the workbook opened. You could cycle through the directory with VBA to get the cell values using this route.

Got a UDF and below is how you'd add it:

  • Open Visual Basic editor in excel (Development tab of the Ribbon - you may need to go into Excel options to unhide it).

  • Right click VBA Project([Your workbookname]), highlight insert and then click module.

  • Paste the below in module1 and save the workbook as a .xlsm.

Code:

Function GetField(Path As String, WorksheetName As String, CellRange As String) As Variant

    Dim wb As Workbook
    Dim ws As Worksheet
    Dim rng As Range

    Set wb = GetObject(Path)
    Set ws = wb.Worksheets(WorksheetName)
    Set rng = ws.Range(CellRange)

    Application.DisplayAlerts = False
    wb.Saved = True            
    wb.Close SaveChanges:=False
    Application.DisplayAlerts = True
End Function

You can then use =GetField() in this workbook only.

Parameters: =getfield("\server5\Operations\MainBoard testing central location DO NOT REMOVE or RENAME\"&A6,"Summary","E9")

Only tested with one file, but you should be able to use cell references, filenames, etc in rows/columns for more than one.

-Confirmed this works on multiple Rows/Columns

Edit: Changed how workbooks are closed from some code provided by Alistair Weir in another issue.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Reference Cell from closed Workbook VBA (with error check and relative path)

From Dev

Saving excel worksheet to CSV with file name from a cell using a macro

From Dev

Saving excel worksheet to CSV with file name from a cell using a macro

From Dev

Cell reference for workbook that changes name every month

From Dev

Excel Cell reference from equation

From Dev

How to create and name an Excel Sheet referencing a cell in the workbook

From Dev

Excel: Using text from a cell as the name of a worksheet in a conditional formatting equation

From Dev

Referencing cell in workbook with variable name

From Dev

Copy workbook name to a cell in another workbook

From Dev

Using VBA to name a cell name box in Excel

From Dev

Reference cell range parameter from other cell dynamically in excel

From Dev

Relative cell reference in Excel using different axis

From Dev

Adding cell values from multiple sheets in Excel workbook via Python

From Dev

VBA macro to save excel file using path from cell

From Dev

excel cell reference in javascript

From Dev

Excel Sumifs with reference to a cell

From Dev

How to exact folder name from an Excel cell?

From Dev

Excel vba function to get value using variables from closed workbook

From Dev

Excel UDF to reference table in closed workbook for lookup

From Dev

reference a cell from another worksheet using a variable

From Dev

reference a cell from another worksheet using a variable

From Dev

Excel Find Cell Name

From Dev

Indirect Sheet name only as a variable, not workbook or cell

From Dev

Define a workbook based on name defined in a cell

From Dev

Exporting data from cell to Excel file

From Dev

What should I do if I see a reference in Excel cell formulas to a sheet that I cannot see in the workbook?

From Dev

How do I extract the row number from a cell reference in Excel using Applescript?

From Dev

How to make cell reference from string without using indirect function [Excel]

From Dev

Excel set cell value on workbook open

Related Related

  1. 1

    Reference Cell from closed Workbook VBA (with error check and relative path)

  2. 2

    Saving excel worksheet to CSV with file name from a cell using a macro

  3. 3

    Saving excel worksheet to CSV with file name from a cell using a macro

  4. 4

    Cell reference for workbook that changes name every month

  5. 5

    Excel Cell reference from equation

  6. 6

    How to create and name an Excel Sheet referencing a cell in the workbook

  7. 7

    Excel: Using text from a cell as the name of a worksheet in a conditional formatting equation

  8. 8

    Referencing cell in workbook with variable name

  9. 9

    Copy workbook name to a cell in another workbook

  10. 10

    Using VBA to name a cell name box in Excel

  11. 11

    Reference cell range parameter from other cell dynamically in excel

  12. 12

    Relative cell reference in Excel using different axis

  13. 13

    Adding cell values from multiple sheets in Excel workbook via Python

  14. 14

    VBA macro to save excel file using path from cell

  15. 15

    excel cell reference in javascript

  16. 16

    Excel Sumifs with reference to a cell

  17. 17

    How to exact folder name from an Excel cell?

  18. 18

    Excel vba function to get value using variables from closed workbook

  19. 19

    Excel UDF to reference table in closed workbook for lookup

  20. 20

    reference a cell from another worksheet using a variable

  21. 21

    reference a cell from another worksheet using a variable

  22. 22

    Excel Find Cell Name

  23. 23

    Indirect Sheet name only as a variable, not workbook or cell

  24. 24

    Define a workbook based on name defined in a cell

  25. 25

    Exporting data from cell to Excel file

  26. 26

    What should I do if I see a reference in Excel cell formulas to a sheet that I cannot see in the workbook?

  27. 27

    How do I extract the row number from a cell reference in Excel using Applescript?

  28. 28

    How to make cell reference from string without using indirect function [Excel]

  29. 29

    Excel set cell value on workbook open

HotTag

Archive