Get Values from Closed File

Pat_The_Bat

Board Regular
Joined
Jul 12, 2018
Messages
82
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

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
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,215,745
Messages
6,126,634
Members
449,323
Latest member
Smarti1

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