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

  • 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...
  • find many based on a certain criteria
    good evening, I hope someone can help me? I have a workbook sheet 2 contains lots of data.... I would like to be able to find anything on sheet...
  • 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...
  • 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#...
  • Text Format
    I have a sheet for user to keyin the data. The format of the data can be 451 / 1903, 0012 / 9908 or 00287 / 0099. The number after the "/" is...
  • Syntax errors
    Good Morning, Trying to compile a workbook, I keep getting a few errors. Here are the first two: [code=rich]Syntax Error: Function...
Top