Source from cell value in Power Query

gelu

Board Regular
Joined
Sep 30, 2022
Messages
85
Office Version
  1. 2021
Platform
  1. Windows
Hello Connoisseurs,

I am trying to get a cell value instead of the absolute address in the code below.

let
Source = Excel.Workbook(File.Contents("C:\AAD\Sheet1.xlsx"), null, true),
Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
#"Changed Type" = .....
in
#"Changed Type"


I have imported a table and drilled down so as to get the address "C:\AAD\Sheet1.xlsx" available in Power Query.
Here I am stuck.

Can anyone help?

Thank you,

GT
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
The easiest is if you give the cell a range name.
In the link below the file name and file path are in a different cell each with a range name.
If you are happy to put the Path & Filename in the 1 cell and give the cell the Range Name "FileName" then the code would look like this:
Replace this:
Power Query:
Source = Excel.Workbook(File.Contents("C:\AAD\Sheet1.xlsx"), null, true),

With this:
Rich (BB code):
    FileName = Excel.CurrentWorkbook(){[Name="FileName"]}[Content]{0}[Column1],
    Source = Excel.Workbook(File.Contents(FileName), null, true),
Note: The M Variable Name can be but does not need to be the same name as the Named Range

For further reading:
Change the Power Query source based on a cell value - Excel Off The Grid
 
Upvote 0
Solution

Forum statistics

Threads
1,215,353
Messages
6,124,463
Members
449,163
Latest member
kshealy

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