有什么方法可以使用Countif()而不过分陈述?
简介
我使用数组公式(Ctrl+Shift+Enter)= sum(countif())
以某些关键字出现多少次。我的问题是,如果在该范围的一个单元格中有一个以上的关键字,则该单元格被多次计数(一次是每个关键字),而我不想要。
示例
我有一个 table 。从A1到A7,我在每个单元格中都有文本。每个单元格包含颜色。它可以是一种颜色,例如“红色”,或许多颜色,例如“红色,绿色,蓝色”。我想计算该系列中出现了多少次“红色”,“绿色”或“蓝色”。我尝试使用公式= sum(countif(a1:a7; {“*”红色*“;”*green*“;”*blue*'}))
,但是如果单元格包含更多与这些颜色之一相比,单元格被多次计数,这不是
问题
我应该使用哪种公式?,以防万一功能或函数的组合要做这,您知道如何创建一个宏来创建所需的公式吗?时间我想使用它们,我可以简单地导入我使用的
较短
- 公式
- 。我不确定如何在标题的问题中总结我的问题。
Introduction
I'm using an array formula (ctrl+shift+enter) =Sum(countif())
to count in a range how many times some keywords appear. My problem is that if in one cell of that range there is more than one keyword, that cell is counted multiple times (once per keyword) and I don't want that.
Example
I have a table. From A1 to A7 I have text in each cell. Each cell contains colors. It can be one color such as "Red", or many such as "Red, Green, Blue". I want to calculate how many times "Red", "Green" or "Blue" appear in the range. I tried using the formula =Sum(countif(A1:A7;{"*"Red*";"*Green*";"*Blue*"}))
, but if a cell contains more than one of these colors, the cell is counted multiple times, and that is not the idea.
Question
Which formula should I use? In case there is no function or combination of functions to do this, do you know how to create a macro to create the needed formula? I have created some formulas in macros, but all of them simply combined formulas that already existed in excel so that I didn't need to write all the long formulas each time I want to use them and instead I could simply import my shorter formula.
Notes
- I use "," for decimal punctuation, that is why I separate arrays and functions with ";".
- Feel free to change the title to something more appropriate. I'm not sure how to summarize my problem in a question for the title. If you do so, then remove this note.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
。
所有版本 将
,
更改为定界符,以使其成为本地设置中的水平数组。而且,不确定这一点,但是在较旧的版本中,这可能需要使用CTRL换档 - 输入编辑模式时输入。
All Versions:
Realize that for me
{"Red","Green","Blue"}
creates a horizontal array. Change the,
to the delimiter to make it a horizontal array in your local settings.And, not sure about this one, but in older version this may require the use of Ctrl-Shift-Enter instead of Enter when exiting edit mode.
您可以在下面尝试promulas
= sum( - ( - ( - ( - isnumber))(搜索({“红色”,“绿色”,“ blue”},a1:a6),a1:a6))= 1),序列(3)) > 0)
在序列3中的此中,因为您有3个值(红色,绿色,蓝色),如果您或多或少只有增加或减少序列,
也可以使用此and
= count(value(iferror) {“红色”},a1:a6),“”)& ifError(search({“ blue”},a1:a6),“”)& ifError(search({“ green”},a1:a6) ,“”))))
You can try below formulas
=SUM(--(MMULT(--(--ISNUMBER(SEARCH({"Red","Green","Blue"},A1:A6))=1),SEQUENCE(3))>0))
In here in the sequence 3 because you have 3 values(Red, Green, Blue) if you have more or less just increase or decrease the sequence
you can also use this one
=COUNT(VALUE(IFERROR(SEARCH({"red"},A1:A6),"")&IFERROR(SEARCH({"blue"},A1:A6),"")&IFERROR(SEARCH({"green"},A1:A6),"")))