简体   繁体   English

Google 表格导入和查询

[英]Google Sheets IMPORTRANGE and QUERY

I'm new to Sheets and the query function as of last night, so don't know the terminology etc - sorry!截至昨晚,我是表格和查询功能的新手,所以不知道术语等 - 抱歉!

I have two workbooks, a master and a template.我有两本工作簿,一个母版和一个模板。 I need the templete to pull specific data from the master when Col2 matches a particular number.当 Col2 匹配特定数字时,我需要模板从母版中提取特定数据。 I have it working great if i manually input the number, but don't want to have to do this everytime I give a copy of the template to a new job.如果我手动输入数字,我会很好地工作,但不想每次将模板副本提供给新工作时都必须这样做。 This number in Col2 is unique to each of the templates I give to a new job, and the number will already be manually input into cell J16 of the template. Col2 中的这个数字对于我提供给新作业的每个模板都是唯一的,并且该数字已经手动输入到模板的单元格 J16 中。 I want the code to pull the number from J16 and search rather than me telling it what the number is everytime.我希望代码从J16提取数字并进行搜索,而不是我每次都告诉它数字是多少。 The code I have that works with the manual input number, in this case 4032 is below.我的代码与手动输入号码一起使用,在这种情况下是 4032 如下。 Thanks in advance for any help.在此先感谢您的帮助。

Vince.文斯。

=QUERY(IMPORTRANGE("1yTp3SajbKovHf_Wjx7CHO9FsIPeQGvmdMytQIkr9gog","Invoices"),"select Col1, Col5, Col11 where Col2 = 4032")

Do you want to get the number (any) from J16 into your query?您想将 J16 中的数字(任意)放入您的查询中吗?

Use:用:

=QUERY(IMPORTRANGE("file_id","Invoices"),"select Col1, Col5, Col11 where Col2 = " & J16)

or better:或更好:

=QUERY(IMPORTRANGE("file_id","Invoices"),a1)

where a1 is:其中 a1 是:

="select Col1, Col5, Col11 where Col2 = " & J16

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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