简体   繁体   English

从单元格访问COUNTIF函数同名工作表的字符串值?

[英]String value from a cell to access worksheet of same name with a COUNTIF Function?

I was looking at this: Use string value from a cell to access worksheet of same name 我当时在看: 使用单元格中的字符串值访问相同名称的工作表

But I want to know how to do that with a CountIF function. 但是我想知道如何使用CountIF函数。 My WorkSheets are named by the Codes in column A3-A12, and that could increase in time. 我的工作表由A3-A12列中的代码命名,并且时间可能会增加。

=COUNTIF('100'!H:H,$B$2)

is how I'm counting all records on Worksheet 100 with the same value as in B2 (it's a date). 这就是我如何计算工作表100上具有与B2中相同的值的所有记录(这是一个日期)。

How do I use =INDIRECT and CountIF together? 如何将= INDIRECT和CountIF一起使用? something like, 就像是,

=INDIRECT(COUNTIF("'"&A4&"'!H:H,$B$2))

That doesn't work, but hopefully you understand what I wish to do. 那是行不通的,但希望您理解我想做的事。

I'm not calculating this function on each worksheet, then using Indirect to grab the values, because everyday those worksheets are blanked. 我不是在每个工作表上都计算此函数,而是使用间接获取值,因为每天这些工作表都是空白的。 So the functions wouldn't stay as well. 因此功能不会保持不变。 But that might be what I have to do, unless I can think of a macro. 但这可能是我必须要做的,除非我能想到一个宏。

Thanks! 谢谢!

Make a string that looks like the argument. 制作一个看起来像参数的字符串。 If: 如果:

=COUNTIF('100'!H:H,$B$2)

works, then so will: 有效,那么将:

=COUNTIF(INDIRECT("'100'!H:H"),$B$2)

If we put the sheet-name in, say cell D4 , then so will: 如果我们输入工作表名称,请说单元格D4 ,那么:

=COUNTIF(INDIRECT("'" & D4 & "'!H:H"),$B$2)

在此处输入图片说明

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

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