简体   繁体   English

如何引用另一个工作表中的单元格?

[英]How to reference a cell from another sheet?

I have to count the number of cells that are not empty in a range, so I must use the COUNTA function. 我必须计算一个范围内不为空的单元格的数量,因此必须使用COUNTA函数。 The problem is, I want it to be dynamic. 问题是,我希望它是动态的。

Steps: 脚步:

First, I have to retrieve the reference of a cell in D column, and the line correspond to the line in A column who contains a specific string. 首先,我必须检索D列中单元格的引用,并且该行对应于A列中包含特定字符串的行。 Let's assume that this string is "NRUTI_02". 假设此字符串为“ NRUTI_02”。

So here is my code 所以这是我的代码

=ADDRESS(MATCH("NRUTI_02";A1:A65535;0);4)

It searchs for the string inside the range A1:A65535 , and once it's found, it applies an offset to get the "D" column (4). 它在A1:A65535范围内搜索字符串,一旦找到,它将应用偏移量以获得“ D”列(4)。 -> If "NRUTI_02" is in A18 , the output will be D18 . ->如果“ NRUTI_02”位于A18 ,则输出将为D18

If I change to another sheet (Sheet1), the code will be the following : 如果我换到另一张纸(Sheet1),则代码如下:

=ADDRESS(MATCH("NRUTI_02";Sheet1!A1:A65535;0);4)

However, to use this formula inside COUNTA , I must use the INDIRECT formula. 但是,要在COUNTA使用此公式,我必须使用INDIRECT公式。 But if I put INDIRECT before my formula, it doesn't work. 但是,如果我将INDIRECT放在我的公式之前,则它不起作用。

How can I use my formula inside COUTNA function please ? 请问如何在COUTNA函数中使用公式?

EDIT : My goal is to have something like COUNTA('Sheet1!'D18:D65535) 编辑:我的目标是要有类似COUNTA('Sheet1!'D18:D65535)

EDIT 2 : COUNTA("Sheet1!D"&MATCH("NRUTI_02";Sheet1!A1:A65535;0):D65535) isn't working 编辑2: COUNTA("Sheet1!D"&MATCH("NRUTI_02";Sheet1!A1:A65535;0):D65535)不起作用

EDIT3 : Real example : My string "NRUTI_02" is in A18. EDIT3:实际示例:我的字符串“ NRUTI_02”在A18中。 The beginning of my range would be D18, because I want to count on column D. The next empty cell in column D is D21. 我的范围的开头是D18,因为我想依靠D列。D列中的下一个空单元格是D21。 I want to count all cells (lines) in range D18:D21. 我想计算范围D18:D21中的所有单元格(行)。 So I'd like my range to be kind of dynamic : the first arg find automatically D18, and the last arg would take the output of the first arg until the end of column. 所以我希望我的范围是动态的:第一个arg自动找到D18,最后一个arg将第一个arg的输出输出到列的结尾。

COUNTA(INDEX(Sheet1!D:D;MATCH("NRUTI_02";Sheet1!A:A;0)):INDEX(Sheet1!D18:D65535;MATCH(TRUE;ISBLANK(Sheet1!D18:D65535);0))) ; 

EDIT4 : Here is what my Excel file looks like : XLSX EDIT4:这是我的Excel文件的样子: XLSX

Doable with INDEX instead of ADDRESS . 可使用INDEX代替ADDRESS

=COUNTA(INDEX(Sheet1!D:D,MATCH("NRUTI_02",Sheet1!A:A,0)):INDEX(Sheet1!D:D,65535))

or even simpler: 甚至更简单:

=COUNTA(INDEX(Sheet1!D:D,MATCH("NRUTI_02",Sheet1!A:A,0)):Sheet1!D65535)

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

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