Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if cell contains wildcard asterisk (*) character

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.

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

like image 259
Matthew Layton Avatar asked Nov 18 '14 21:11

Matthew Layton


People also ask

Is * a wildcard in Excel?

Wildcards in Excel are the special Excel characters that take the place of the characters in it. Excel has three wildcards: an asterisk, question mark, and tilde. Asterisk is used for multiple numbers of characters in Excel, while a question mark represents only a single character.


1 Answers

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.

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

like image 154
user3885927 Avatar answered Nov 16 '22 02:11

user3885927