If a cell contains certain word.

jevi

Board Regular
Hi All,

I'm trying to do this formul but is not working.

=IF(ISNUMBER(SEARCH("*LR 10*";A2));"M01";B2)

so in column A2 I have the long desription of the loan and I want to find the ones that contain "LR 10", and if this is true to put in cell C2 "M01" otherwise the value that is in cell B2. But is not giving the result I want.

So I need help...thank you:)
 
Last edited:

Peter_SSs

MrExcel MVP, Moderator
Hmm, seems to work for me. In what way is it "not giving the result I want"?
Some sample data maybe?

Also, whilst they won't do any harm, you don't need the asterisks in that formula.

Note that my formula delimiter is "," not ";" like yours.

Excel Workbook
ABCD
2Some long description including LR 10 and other textxxx
3Some long description including LR 11 and other textyyyyyyyyy
SEARCH
 
Last edited:

Fluff

MrExcel MVP, Moderator
If the data in col A has come from a website or some other 3rd party software, the spaces maybe non-breaking spaces, in which case try
=IF(ISNUMBER(SEARCH("LR?10",A2)),"M01",B2)
Although this will pick-up any instance where you have LR & 10 separated by a single character.
 

Peter_SSs

MrExcel MVP, Moderator
If the data in col A has come from a website or some other 3rd party software, the spaces maybe non-breaking spaces,...
Good point, and we could target that &/or space specifically with

=IF(ISNUMBER(SEARCH("LR 10",SUBSTITUTE(A2,CHAR(160)," "))),"M01",B2)
 

jevi

Board Regular
Thank you to all of you for the answers. Now that I did the test from the home computer is working my formula but because I wrote the test LR 10 in the excel file while at office is not working. The test that i have in the office is in txt extracted from another program so I will use "?" and the other formula. I will try on monday and let you know if it is working, but I guess was not working as Pluff said as it is a text from another program.

Have a nice weekend all of you.
 

Fluff

MrExcel MVP, Moderator
If you are likely to something like LRP10 in the cell and it should return B2 rather than "M01", then you are better off using Peter's code.
 

Some videos you may like

This Week's Hot Topics

  • Get External Data (long shot question!)
    This is likely a long shot but I am wondering if it is at all possible for Excel to somehow 'change' the contents of a URL that is being linked to...
  • Importing multiple excel files into one spreadsheet
    Hi, I'm trying to import multiple excel files (with the same format into a single spreadsheet) so that each day's file is listed underneath the...
  • Cell Formatting
    Good Morning, I need to format a few different cells in the following manners: A1 has to always add a colon (:) after whatever is typed in by a...
  • How to copy multiple rows using If
    Hi all, I'm very new to VBA and have written this simple code to copy certain cells if a certain cell within that row contains any data. I need...
  • Workbook_Change stopped working !
    I am working on an app to speed up & automate processing of Credit Cards statements. After data is input from a CSV file, it is presented to the...
  • VBA If statement
    Dear All, I have two dates, where I'd like a message box to pop, if the dates are between this criteria. [CODE] sDate1 = #10/1/2019#...
Top