Excel:将文本解析为公式
我希望 Excel 公式的一部分是动态的,而不是单元格引用。
例如,假设在 A 列(单元格 A1:A99)中我有一堆数字,我想知道其中有多少数字大于 50。
如果我希望此计算是静态的,我可以简单地使用一个以下内容:
=COUNTIF($A$1:$A$99,">50")
=SUM(IF($A$1:$A$99>50,1,0))
=SUM(($A$1:$A$99>50)*1)
我提到这三个是因为我的实际公式很复杂,并且有点混合了第二个和第三个。 (毕竟,也许有些东西适用于 COUNTIF,但不适用于其他单元格。)
现在,我希望能够在另一个单元格中输入我的条件(例如 C1)。因此,如果我在 C1 中输入“>50”,我的计算将如上,但如果我输入“<100”,我将计算 A 列中有多少条目小于 100。
这可能吗? (我在 Windows XP 上使用 Excel 2003。)
I would like to have part of an excel formula be dynamic, other than a cell reference.
For instance, suppose that in column A (cells A1:A99) I have a bunch of numbers, and I want to know how many of those numbers are greater than 50.
If I wanted this calculation to be static, I could simply use one of the following:
=COUNTIF($A$1:$A$99,">50")
=SUM(IF($A$1:$A$99>50,1,0))
=SUM(($A$1:$A$99>50)*1)
I mention all three because my actual formula is hairy and a bit of a mix of the second and the third. (After all, perhaps something will work with COUNTIF but not with the others.)
Now, I want to be able to type my condition in another cell (say C1). So if I type ">50" in C1, my calculation will be as above, but if I type "<100" I will count how many entries of column A are less than 100.
Is this possible? (I am using Excel 2003 on Windows XP.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我可能缺少一些东西。
如果您
输入任何单元格,然后在单元格 C1 中输入 >50 或 <100
你没有得到你想要的吗?
There may be something that I'm missing.
If you give
in any cell, and then in cell C1 you type >50 or <100
don't you get what you want?
使用
INDIRECT
与
但是,正如您所确定的,前者,您可以在Excel单元格内生成!我一直这样做,对于这样的事情。
Use
INDIRECT
is same as
But, as you identified, the former, you can generate within the excel cells! I do it all the time, for such things.
我通常通过添加另一列承载复杂逻辑表达式的结果来解决这个问题,就像
这个公式位于 F 列的所有行中一样 - 注意:这里不需要 IF!
然后我使用 =SUMIF() 计算 E 列的复杂条件总和,就像
我知道有些用户说“我不想改变我的设计。没关系;我的论点是我可以更好地控制条件,我可以工作条件与依赖于该条件的求和或其他函数分开,我可以过滤 TRUE 或 FALSE 的记录来查看子集,并快速概览公式是否有意义
希望有帮助祝你好运 MikeD
I usually solve this by adding another column carrying the result of a complex logical expression, like
this formula is in all rows of -say- column F - note: no IF needed here!
then I calculate a complex conditional sum across column E using =SUMIF() like
I know that some users say "I do not want to change my design. That's ok; my argument is that I have better control over the condition, I can work on the condition seperately from summing up or other functions that rely on that condition, and I can filter records for TRUE or FALSE to look at the subsets and have a rapid overview if the formula makes sense
hope that helps Good luck MikeD