如何检查单元格是否包含通配符星号(*)字符

时间:2022-09-13 09:31:39

Consider the following two formulas:

考虑以下两个公式:

=IF(SEARCH("*", A1), "true", "false")

=IF(SEARCH(CHAR(42), A1), "true", "false")

I am using this to try and detect if a cell contains a * character, but this returns "true" for all cells. I can only assume that Excel sees * as a wildcard maybe.

我使用这个方法来检测一个单元格是否包含一个*字符,但是对于所有的单元格,它返回的是“true”。我只能假设Excel将*视为通配符。

How do you detect the existence of a * in Excel?

你如何判断一个*在Excel中的存在?

1 个解决方案

#1


12  

According to this reference of microsoft you should be able to use ~

根据微软的参考资料,你应该能够使用~

Microsoft Excel uses the tilde (~) as a marker to indicate that the next character is a literal. When you use the Find and Replace dialog box to find or replace a character such as a tilde (~), an asterisk (*), or a question mark (?), you must add a tilde (~) before the character in the Find what box.

Microsoft Excel使用波浪号(~)作为标记,表示下一个字符是文字。当您使用“查找和替换”对话框查找或替换字符(如波浪号(~)、星号(*)或问号(?)时,您必须在“查找什么”框中的字符之前添加波浪号(~)。

So change =IF(SEARCH("*", A1), "true", "false") to =IF(SEARCH("~*", A1), "true", "false") and it should work.

所以change =IF(SEARCH("*", A1), "true", "false") =IF(SEARCH("~*", A1), "true", "false")

#1


12  

According to this reference of microsoft you should be able to use ~

根据微软的参考资料,你应该能够使用~

Microsoft Excel uses the tilde (~) as a marker to indicate that the next character is a literal. When you use the Find and Replace dialog box to find or replace a character such as a tilde (~), an asterisk (*), or a question mark (?), you must add a tilde (~) before the character in the Find what box.

Microsoft Excel使用波浪号(~)作为标记,表示下一个字符是文字。当您使用“查找和替换”对话框查找或替换字符(如波浪号(~)、星号(*)或问号(?)时,您必须在“查找什么”框中的字符之前添加波浪号(~)。

So change =IF(SEARCH("*", A1), "true", "false") to =IF(SEARCH("~*", A1), "true", "false") and it should work.

所以change =IF(SEARCH("*", A1), "true", "false") =IF(SEARCH("~*", A1), "true", "false")