Get Values from Closed File

Pat_The_Bat

Board Regular
Joined
Jul 12, 2018
Messages
83
I need to get values from another file on the server. I don't want to open the file. Is there a way to reference a cell in a closed file?
Really appreciate any help that you can give!
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
You sure can, the reference will look like this.

='filelocation\[filename]sheetname'!cell

='C:\Users\andrew.mathews\Desktop\[Book7.xlsx]Star Chart'!$AD$121
 
Upvote 0
come across this before and it works, though unsure how :D

Code:
Option Explicit


Sub Sample()
    Dim wbPath As String, wbName As String
    Dim wsName As String, cellRef As String
    Dim Ret As String


    wbPath = "C:\testing\aaa\"


    wbName = "a1.xlsx"
    wsName = "Sheet2"
    cellRef = "G19"


    Ret = "'" & wbPath & "[" & wbName & "]" & _
          wsName & "'!" & Range(cellRef).Address(True, True, -4150)


    Range("A1").Value = ExecuteExcel4Macro(Ret)
End Sub
 
Upvote 0
or try PowerQuery. You'll be allowed to choose: table, set of data, cell, cells etc.
(Excel 2010/2013 add-in, 2016 and higher - built-in)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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