简体   繁体   English

Excel-基于另一个单元格中的字符串模式创建值

[英]Excel - create a value based on string pattern in another cell

I have one column in my worksheet that contains values like: 我的工作表中有一列,其中包含以下值:

1,2
1,3,265
3,6,145,205
7,6,112
216,269,270,330

I would like to create a value ('Yes') in another cell where the first cell has x,x,x,x (four comma separated values) and default to 'No' where the first cell has three or less comma separated values. 我想在第一个单元格具有x,x,x,x(四个逗号分隔值)的另一个单元格中创建一个值(“是”),并在第一个单元格具有三个或三个以下逗号分隔值的情况下默认设置为“否” 。

In the case above, the result would look like: 在上述情况下,结果如下所示:

1,2               No
1,3,265           No
3,6,145,205       Yes
7,6,112           No 
216,269,270,330   Yes

The values themselves are unimportant - I just need to evaluate the string pattern. 值本身并不重要-我只需要评估字符串模式。

Sorry if that's explained elsewhere here, I could find it. 抱歉,如果在这里其他地方有解释,我可以找到。

Just count the number of commas: 只需计算逗号数:

=if((LEN(A1)-LEN(SUBSTITUTE(A1,",","")))>2,"Yes","No")

And ensure that the values are text and not numbers formatted to show comma separators. 并确保这些值是文本格式,而不是数字格式,以显示逗号分隔符。

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

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