I want to access another document using a filepathlink formula but take part of the name from a cell

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,
Currently in cell H2 I have the following formula
=SUM('https://hcr.sharepoint.com/sites/Finance/Shared Documents/Finance - Confidential/Accounts/Mgmt Accounts/Project Reports/2022_Proj/21122001/[21122001_Dashboard.xlsm]Sales'!$G:$G)
which works great at pulling in a figure from this other sheet.
What I want to do is instead of having the number "21122001" in the formula, have it in cell B2 and look it up, but everything I'm trying doesn't seam to work,
any ideas how i could get this to work?
Thanks
Tony
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
You can use INDIRECT, but it will only work, if the linked document is open!
220723.xlsm
A
13
24
Sheet1
Book1.xlsm
AB
1Path_Ahttps://d.docs.live.net/b94bc0f382aae2aa/Desktop/
2Path_Btest/2022-07-23
3Pathhttps://d.docs.live.net/b94bc0f382aae2aa/Desktop/test/2022-07-23/220723.xlsm
4Filename220723.xlsm
5
67
77
Sheet6
Cell Formulas
RangeFormula
B3B3=B1&B2&"/"&B4
A6A6=SUM(INDIRECT("'"&B1&B2&"/["&B4&"]Sheet1"&"'!A1:A2"))


If you don't want to open the workbook you can use VBA to do the job:

VBA Code:
Sub getDataFromWB()
   Dim Path_A, Path_B, Path_X, FileNameWB As String
   Dim WB As Workbook
   Dim Sum As Double
   Application.ScreenUpdating = False
   Path_A = ThisWorkbook.Sheets("Sheet6").Range("B1")
   Path_B = ThisWorkbook.Sheets("Sheet6").Range("B2")
   FileNameWB = ThisWorkbook.Sheets("Sheet6").Range("B4")
   Path_X = Path_A & Path_B & "/" & FileNameWB
   Set WB = Workbooks.Open(Path_X)
   Sum = WorksheetFunction.Sum(WB.Sheets("Sheet1").Range("A1:A2"))
   ThisWorkbook.Sheets("Sheet6").Range("A7").Value2 = Sum
   WB.Close savechanges:=False
   Application.ScreenUpdating = True
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,426
Messages
6,119,414
Members
448,895
Latest member
omarahmed1

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