IF, and LEFT, with wildcards...

Tomkat53

Board Regular
Joined
Oct 22, 2010
Messages
61
Greetings...
I have a formula that ALMOST works...
I need it to look at the LEFT 5 characters in Column C (label_description), and if they match the format "*** - *" then I need it to return just the first 3 characters.
If it's false, I need it to return "OB" & the RIGHT 3 characters from column A (label_code)
The problem is, I'm having difficulty getting the wildcards to work properly. Apparently "IF" cannot use wildcards, but COUNTIF can, so I have to combine them as follows...

1640017782091.png


As you can see the formula works until row 45... it WANT IT to return "OB506" but it returns "Car" because column C contains "*** - *" (where indicated by red rectangle.)
HOW do I get the formula to ONLY consider the LEFT 5 characters?
I have searched for a solution for quite awhile, but I seem to be running in circles.
I have hundreds of records in this table, and would really like to not have to "fix" each record manually.
 

Attachments

  • 1640017350738.png
    1640017350738.png
    48.9 KB · Views: 5
Last edited:

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Try replace the *** with ??? that way it should look for 3 characters followed by a space & hyphen.
 
Upvote 0
Solution
Try replace the *** with ??? that way it should look for 3 characters followed by a space & hyphen.

Thanks for the quick reply, but that doesn't work ( I had already tried "?") as it just causes "FALSE" for every cell.
 
Upvote 0
Did you replace all the * with a ? or just the first three?
 
Upvote 0
In that case just replace the first 3 & leave the rest of the formula as-is.
 
Upvote 0
An * represents any number of characters (including 0), whilst the ? represents one character only.
 
Upvote 0
OK, but why does it now work properly in row 45 in my example above?
Shouldn't "ngs - A" (??? - *) in the middle of the text string still trigger a match?
 
Upvote 0
After thinking about it.... I'm guessing the "COUNTIF" function BEGINS from left to right, by default?
 
Upvote 0

Forum statistics

Threads
1,215,584
Messages
6,125,673
Members
449,248
Latest member
wayneho98

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