views:

2077

answers:

1

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.

A: 

=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.

Dick Kusleika
$DATA is a typo due to copying the function from Open Office (which converts formulas to StarBasic). It should say DATA! as it is a worksheet reference.
SpliFF
This solution fails because search raises a #VALUE error when the string is not found. This breaks the whole formula. Same with FIND. Is there a way to test for #VALUE?
SpliFF
never mind. IF(NOT(ISERROR(FIND($B$3,DATA!$A$2:$A$1501)=1)))
SpliFF
If you're using 2007, you can use the IFERROR function as an alternative
Dick Kusleika