vba 通过更改单元格值更改公式内的工作表名称

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23859756/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 03:14:26  来源:igfitidea点击:

Change sheet name inside formula by changing cell value

excelvbaexcel-vba

提问by Mouneer

I have this formula:

我有这个公式:

=COUNTIF('5-5-2014'!H:H;"NEW")

and I have cell K9 have a value of "5-5-2014". I want to modify this formula so that I could change sheet name inside formula by changing cell K9 Value. So I want something like this:

我有单元格 K9 的值为“5-5-2014”。我想修改这个公式,以便我可以通过更改单元格 K9 值来更改公式中的工作表名称。所以我想要这样的东西:

=COUNTIF('K9'!H:H;"NEW")

I know this formula is totally wrong! Is there any way doing that?!

我知道这个公式是完全错误的!有什么办法吗?!

回答by Rick

=COUNTIF(INDIRECT("'"&K9&"'!H:H"),"NEW")Where K9 contains the sheet name

=COUNTIF(INDIRECT("'"&K9&"'!H:H"),"NEW")其中 K9 包含工作表名称