wild character in IF

22strider

Active Member
Joined
Jun 11, 2007
Messages
311
Hello Friends

Could you please see the following formula and tell why it won't work?

=IF(B2 = "SGS*", I2, B2)

basically it is checking if text in B2 starts with "SGS"; if yes then text from cell "I2" should be brought in otherwise B2.

There are other ways to do this but it not working has gotten me curious.

Thanks
Rajesh
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Hi Rajesh

You cannot use wildcards with the equal operator.

Try:

=IF(LEFT(B2,3) = "SGS", I2, B2)
 
Upvote 0
Hi

The Like operator is a vba operator, does not work in formulas.

I don't see why you want to use the wildcard when the Left() function solves the problem.

If you really want to use the wildcard you could for ex. use the CountIf() function, but it is much less efficient, for ex.:

=IF(COUNTIF(B2,"SGS*")=1,I2,B2)
 
Upvote 0
Thanks PGC
As I said, I just got curious about using wildcard. I've been using SQL and VBA quite a bit and took it for granted that the wildcards would work.
Thanks again for the explanation.
 
Upvote 0

Forum statistics

Threads
1,224,525
Messages
6,179,317
Members
452,905
Latest member
deadwings

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top