简体   繁体   中英

referencing cell value in power Query from different worksheet

I need to create several workbooks with power query which pulls prices for respective CustomerCode . I want to pull data based on a cell value from a different worksheet in that workbook

let's say I have sheet1 cell("H9").value where it has the customer code, and another worksheet Price with power query.

in the power query formula, I have hard coded as below,

= Table.SelectRows(#"Changed Type", each ([CustomerCode] = 123456))

but I want this CustomerCode to be a variable, referencing sheet1 Cell("H9").value ,

= Table.SelectRows(#"Changed Type", each ([CustomerCode] = sheet1.Cell("H9").value ))

so when I create different workbooks with changed value in sheet1 Cell("H9").value , it will automatically pull the data for respective CustomerCode without having to go in the query to change the CustomerCode

I am quite new to power query, can it be done in power query formula?

Thanks for your help in advance.

I don't know about a cell address, but you can access data from a Named Range

So, if Customer_Code refers to: Sheet1!H9 , you can use, in your code:

CustomerCode = Excel.CurrentWorkbook(){[Name="Customer_Code"]}[Content][Column1]{0}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM