NorwegianLatte
NorwegianLatte

Reputation: 89

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.

Upvotes: 1

Views: 6188

Answers (1)

Ron Rosenfeld
Ron Rosenfeld

Reputation: 60474

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}

Upvotes: 1

Related Questions