How to match a string wildcard pattern in an excel

2019-08-31 02:37发布

I have a test like

LEFT('F13',2)='F1'

I want to change it from a left-side match to a test that supports wildcards

'F13'='F?3'

Excel doesn't support regex except in VBA code but i'd prefer this was done in a macro. I should point out that the actual test isn't a simple string, but cell references (this may be important, I'm not sure):

IF(LEFT($DATA.$A$2:$A$1501,LEN($B$3))=$B$3,...

The range actually evaluates to a single cell based on where the macro is called from. $B$3 is the pattern input by the user.

1条回答
做个烂人
2楼-- · 2019-08-31 03:29

=SEARCH("F?3","F13")=1

In your second example, if B3 contains wildcards infused text

=SEARCH(B3,$DATA.$A$2:$A$1501)=1

SEARCH returns the position where it finds the first argument. The "=1" ensures the string starts with the first argument as opposed to somewhere in the middle. I'm not sure how your $DATA argument works, so I just copied it verbatim.

查看更多
登录 后发表回答