MS Excel: Search, Find and Extract Specific Text Cell containing text string - string

Although, I've seen relatively similar or close postings
Using MS Excel MS Excel 2010, I would like to be able to search Cell Range (Column A1:A25), to find if specific text within Cell String (Column C2) is a match in Cell Range (A1:A26) and then Output the corresponding matching Keyword results found in same or adjacent cell. If matching text is not found then display "No Match Found"
Although the sample formula shown below that I'm using does work, but only indicates it found or did not find word within Cell Range I need for it to return the actual matching Keyword text found versus "FOUND" OR "NOT FOUND".
=IF(SUM(IFERROR(FIND(A1:A26,C2),0))>0, "FOUND", "NOT FOUND")
Example:
Cell String contains the following text in Cell C2:
"I found a lost German Sheppard in my backyard on yesterday"
Keyword Search Words: Column A1:A26
TYPES OF DOGS
Affenpinscher
Afghan Hound
Airedale Terrier
Akita
Alaskan Malamute
American Foxhound
American Staffordshire Terrier
American Water Spaniel
Anatolian Shepherd
French Bulldog
German Pinscher
German Shepherd
German Shorthaired Pointer
German Wirehaired Pointer
Giant Schnauzer
Glen of Imaal Terrier
Golden Retriever
Gordon Setter
Great Dane
Greater Swiss Mountain
Great Pyrenees
Greyhound
Harrier
Irish Setter
Irish Terrier
The Returned and displayed results/answer = German Sheppard
Please let me know if this possible, as I would greatly appreciate any assistance to resolving my question.
Miaka3

Assuming you are searching column A for a string(s) in column C type this array formula in B:
=IFERROR(INDEX($C$2:$C$6,MAX(IF(ISERROR(FIND($C$2:$C$6,A2)),-1,1)*(ROW($C$2:$C$6)-ROW($C$2)+1))), "None")
You can see here that I have a search list of multiple characters/strings in C2 through C6. If one of the search strings is found, it will be listed in column B, otherwise it will display "None".
The key to this working is copy the above formula into cel B2 and while you are still in edit mode pressing Ctrl+Shift+Enter instead of just Enter like usual. You will know it works correctly if you see the addition of { and } in the formula once you hit the three key combination. After that you can copy the formula down through A25 or wherever you need.
Note you can make your Search List longer or shorter as needed, just make sure to update your formula to reflect the range. You will want to fill in all of you dog breeds in Column C and change every $C$2:$C$6 in the formula to equal your search list range. And, remember, any change to the array formula requires Ctrl+Shift+Enter to work properly.

This isn't what Excel was designed for, but you can accomplish it with a helper column. Insert a new column at B (this will move C2 to D2). Then paste this formula into B2:
=IF(ISERROR(FIND(A2,D$2)),"",A2)
Fill down that formula until A27 (you said A26, but your example went to A27 if you include the header "TYPE OF DOGS"). This will output the breed of the dog only if it is contained within the text in D2.
Finally, go to whatever cell you would like to contain your output, and paste in:
=CONCATENATE(B2,B3,B4,B5,B6,B7,B8,B9,B10,B11,B12,B13,B14,B15,B16,B17,B18,B19,B20,B21,B22,B23,B24,B25,B26,B27)

Related

How to highlight cell that does not contain specific text from any column

I have a excel file with 2 excel sheet. The sheets are called first and second.
For the first sheet, it contain 1 column, animal while the other sheet, it contains 1 columns, sentence.
name of the 1st sheet: first
animal
cat
fly
deer
dog
deer
snail
name of the 2nd sheet: second
sentence
thedogpoops
thedeerismyinhouse
where is my cat
theflyis annoying
In the first sheet, if any of the animal is not contained in the second sheet, it should be highlighted. "snail" should be highlighted in animal sheet
I used search excel formula to do this. I go to conditional formatting and use a formula to determine which cells to format. I implemented the code
=NOT(ISNUMBER(SEARCH('Sheet 1'!$A:$A,$A:$A)))
The output is that the whole animals is highlighted
What I am trying to do is that if the animal is not found in any of the column, it will be highlighted. However it does not work. Can you please correct this problem?
Based on your example this should work:
=if(A3="","",if(count(search(A3,second!$A:$A))>0,":-)",":-("))
ARRAY FORMULA press SHIFT + CTRL + ENTER to enter formula
You can place that beside the animal and pull it down.
You can use conditional formatting on the list to highlight like in my case ":-(" the sad smiley or you use better visible letters for highlighting.
If you just want to highlight the "missing" animals, then delete the happy smiley from the formula.
=if(A3="","",if(count(search(A3,second!$A:$A))>0,"",":-("))
ARRAY FORMULA press SHIFT + CTRL + ENTER to enter formula
Select column A on the Animals worksheet and create a CFR based on this formula,
=isna(match("*"&$A1&"*", 'Sheet 2'!$A:$A, 0))
By 'wildcarding' the match to the value in the 'Animals' worksheet you are creating a 'contains within' criteria to any string in Sheet 2's column A like the non-case-sensitive SEARCH function.
Rather than produce a series of images on how to do it manualy, this is the VBA equivalent.
With worksheets("Animals").range("a:a")
.FormatConditions.Delete
with .FormatConditions.Add(Type:=xlExpression, Formula1:="=isna(match(char(42)&$A1&char(42), 'Sheet 2'!$A:$A, 0))")
.Interior.Color = vbred
end with
End With
When a cell contains an error like #VALUE! this is not text with those the phrase "VALUE"; not something you can (or should) search for in this way. It is a sort of placeholder showing where an error is.
To determine whether a formula or function results in an error use ISERROR or IFERROR.
For example, if you want to return Not Found if your formula produces an error, you could use:
=IFERROR(SEARCH($A:$A,'Sheet 2'!$A:$A),"Not Found")
I prefer VLOOKUP for finding matches.
For example, you could enter in cell B2 on sheet First:
=VLOOKUP("*" &A2&"*",second!$A$2:$A$5,1,FALSE)
...and then fill or copy the formula down to cell A7.
If a matching phrase is found in Second then it will show that phrase, otherwise it will produce an error.
This time using ISERROR (as well an IF) as an example, you could display whether or not there was a match by instead using this formula in cell B2 on sheet First:
=IF(ISERROR(VLOOKUP("*"&A2&"*",second!$A$2:$A$5,1,FALSE)),"No Match","Matched!")
...and then fill or copy the formula down to cell A7.
More Information:
TechOnTheNet : How to use the ISERROR Function
ExcelJet : How to use the Excel IFERROR Function

Excel: Search for many text strings in a cell, and return all positive results

I need a function that will search a cell for many keyword text strings (model numbers) and return each model number that it finds. In all my research I have only found solutions that provide one matching keyword, but I would like all matching keywords.
An example of a solution only finding one keyword: Excel: Search for a list of strings within a particular string using array formulas?
Example of what I would like:
Cell to search in (A1) contains:
A-007858 CustomerCompanyName D1001, S1135, BE60 and R235 New 6 and 8 Packs
Search Keywords (on separate worksheet A1-A70):
A32: D1001
A43: S1135
A6: BE60
A64: R235
Desired Output:
Each model number found (D1001, S1135, BE60, R235) displayed in cells B1, C1, D1, and E1 next to the cell that was searched (A1). The order of the model numbers is not important. I would prefer an Excel function solution rather than VBA.
Put this formula in B1 and copy over:
=IFERROR(INDEX(Sheet2!$A$1:$A$70,AGGREGATE(15,6,ROW(Sheet2!$A$1:$A$70)/(ISNUMBER(SEARCH(Sheet2!$A$1:$A$70,$A1))),COLUMN(A:A))),"")
Replace Sheet2 with the name of the sheet on which your list resides.
It will be in order of the list on the other sheet.
If you don't have too many keywords you can do this fairly simply:
B1 = IF(ISERROR(SEARCH("D1001",A1)),"","D1001")
where you can replace "D1001" with a reference to the cell in the other sheet. C1:E1 would be analogous.
If you have a lot, then you'll need something more involved like #ScottCraner suggests.

Excel Formula - If contains text, result text

I've got a weird Excel problem that is giving me a mind block. Basically, this is what I've got:
Column A contains strings of text, which all contain company names and a bunch of other info. I'd like to strip out those names. I've got a list of the names I'm searching for.
**Contractor**
CompanyA
CompanyB
CompanyC
CompanyD
And strings like this:
CompanyA REQ# G-FMR-036 PT 2
CompanyA Pad AN Structural Steel ()
COMPANYC REQ# 54
CompanyA REQ# G-FMR-049
What I would like is the formula to return whichever of the company names appears in that string. My first thought was a giant nested formula of IFs and SEARCHes but I know there has to be a better way.
With the list to search in A1:A4 and the list of company names in B1:B4, this array formula, entered with CtrlShiftEnter will do it:
=INDEX($B$1:$B$4,MATCH(TRUE,ISNUMBER(SEARCH($B$1:$B$4,A1)),0))
A bit of a kludge but better than nested IFs:
I am explaining for the example you gave above (4 companies); you should be able to figure out how to extend this.
In column A have your strings that include company names and the extra stuff. Let's assume A1 has some column title, and your 4 strings are in A2, A3, A4, A5.
In cells C1, D1, E1, F1 have the "clean" four company names.
In C2 have this formula:
=IF(ISERROR(FIND(UPPER(C$1), UPPER($A2))),"",C$1)
Then copy cell C2 to all the cells in C2:F5 . The formula will update automatically to fit each cell.
Then, in cell H2 have this formula:
=C2&D2&E2&F2
and then copy/paste it to H3, H4, H5.
In column H you will get what you are looking for.
Of course this assumes you have only one matching company name in each cell in column A, and that the names are exactly (up to case-sensitivity) the same as the company names in cells C1:F1 .
I take it that some of the company names contain spaces, otherwise you could just use:
=left(a1,find(" ",a1)-1)
If you need to compare the contents of the string against a list of companies, then with the list in a named range "CompanyList"; one entry per row; you could try something like:
=IFERROR(LOOKUP(2,1/ISNUMBER(SEARCH(CompanyList&"*",A1)),CompanyList),"Not in List")
However, if some names are similar, you will need to pay attention to the order in the list, as the formula will return the last entry that matches. So you want to put the longest string in Company List last.
This is what I've created so far, although I imagine there has to be a better way than nested formulas like whoa. I mean, it works, but it makes me want to cry.
=IF(ISNUMBER(SEARCH(T$3,B3)),"CompanyA",IF(ISNUMBER(SEARCH(T$4,B3)),"CompanyB",IF(ISNUMBER(SEARCH(T$5,B3)),"CompanyC",IF(ISNUMBER(SEARCH(T$6,B3)),"CompanyD","Other"))))

Extract a value from a cell if it matches a list of characters

I'm trying to extract a word from a sentence if it starts with one of the following letters.Dell** or Samsung** or Apple**. The position of the words may vary in the cell.
A1: Dell2622 Retail34792 Lenovo StoreQuantity4
A2: Retail9858 Qty8 Samsung783546 Android
A3: Retail21512 Apple3411 StoreQty15 Macintosh
I am trying to use the following formula to extract the Dell** or Samsung** or Apple** if it's present int the cell.
=MID(A1, SEARCH({"Dell","Samsung","Apple"},A1), SEARCH(" ",A1, SEARCH({"Dell","Samsung","Apple"},A1))- SEARCH({"Dell","Samsung","Apple"},A1))
It works for the cell A1, but everything else returns #VALUE!. I guess it doesn't recognize that i want it to check for either or and extract either or. The result I'm trying to achieve is:
A1: Dell2622
A2: Samsung783546
A3: Apple3411
Later on i may need to add more things to search for, so I'm trying to keep it easily modifiable. I guess since it finds the first instance, then it's just a matter of tweaking something to ensure that if it didn't find the first value it looks for second, etc.
Assuming you have a data setup similar to the picture below, with your strings in column A, the formula in column B, and the words to look for in column D:
The formula in cell B2 and copied down is:
=TRIM(LEFT(SUBSTITUTE(MID(A2,MIN(INDEX(SEARCH($D$2:$D$4,A2&$D$2:$D$4),)),255)," ",REPT(" ",255)),255))
And per your request to not use a range reference and instead have the list of words directly in the formula:
=TRIM(LEFT(SUBSTITUTE(MID(A3,MIN(INDEX(SEARCH({"Dell","Samsung","Apple"},A3&{"Dell","Samsung","Apple"}),)),255)," ",REPT(" ",255)),255))

Find something in column A then show the value of B for that row in Excel 2010

Basically my problem is that I have a string in one cell in excel, I then need to see if that string exists in another row (not one cell but the whole row) and if so then print the contents of another cell in the same row but in another column.
I will give a basic example:
Title Answer
Police 15
Ambulance 20
Fire 89
Now I need to scan the title column for, say, "Police" and then populate the cell with the value under Answer (in this case 15).
I cant just say IF(A2="Police";B2;"" as I need the scan the whole of the Title column.
I have tried using IF(COUNTIF(A$2:A$100;"Police"); which scans the contents of A2 to A100 for the string Police, and know how to make it print a constant (just put something after the ;) but cant work out how to make that "constant" a variable that changes depending on the found row. So if the COUNTIF found Police in cell A44 then the answer to my formula would be B44, the same as if it found Police in A62 then my formula should show B62
I hope this makes sense and that someone can help me :)
Note that I am using excel 2010 and need a normal formula as I can not use scripting for this document.
EDIT:
Here is what I have so far, note that the spreadsheet I am using is far more complex than the "simple" example I have in the question...
=IF(ISNUMBER(FIND("RuhrP";F9));LOOKUP(A9;Ruhrpumpen!A$5:A$100;Ruhrpumpen!I$5:I$100);"")
This is showing "RuhrP" in every answer where "RuhrP" is found in F9 and not the answer I want which should be that found in RuhrPumpen!I$5:I$100 where the cell index is the same as that for the A coloum where A9 was found. Again, sorry for the complexity I cant think of any better way to word it.
I note you suggested this formula
=IF(ISNUMBER(FIND("RuhrP";F9));LOOKUP(A9;Ruhrpumpen!A$5:A$100;Ruhrpumpen!I$5:I$100);"")
.....but LOOKUP isn't appropriate here because I assume you want an exact match (LOOKUP won't guarantee that and also data in lookup range has to be sorted), so VLOOKUP or INDEX/MATCH would be better....and you can also use IFERROR to avoid the IF function, i.e
=IFERROR(VLOOKUP(A9;Ruhrpumpen!A$5:Z$100;9;0);"")
Note: VLOOKUP always looks up the lookup value (A9) in the first column of the "table array" and returns a value from the nth column of the "table array" where n is defined by col_index_num, in this case 9
INDEX/MATCH is sometimes more flexible because you can explicitly define the lookup column and the return column (and return column can be to the left of the lookup column which can't be the case in VLOOKUP), so that would look like this:
=IFERROR(INDEX(Ruhrpumpen!I$5:I$100;MATCH(A9;Ruhrpumpen!A$5:A$100;0));"")
INDEX/MATCH also allows you to more easily return multiple values from different columns, e.g. by using $ signs in front of A9 and the lookup range Ruhrpumpen!A$5:A$100, i.e.
=IFERROR(INDEX(Ruhrpumpen!I$5:I$100;MATCH($A9;Ruhrpumpen!$A$5:$A$100;0));"")
this version can be dragged across to get successive values from column I, column J, column K etc.....
Assuming
source data range is A1:B100.
query cell is D1 (here you will input Police or Fire).
result cell is E1
Formula in E1 = VLOOKUP(D1, A1:B100, 2, FALSE)
I figured out such data design:
Main sheet:
Column A: Pump codes (numbers)
Column B: formula showing a corresponding row in sheet 'Ruhrpumpen'
=ROW(Pump_codes)+MATCH(A2;Ruhrpumpen!$I$5:$I$100;0)
Formulae have ";" instead of ",", it should be also German notation. If not, pleace replace.
Column C: formula showing data in 'Ruhrpumpen' column A from a row found by formula in col B
=INDIRECT("Ruhrpumpen!A"&$B2)
Column D: formula showing data in 'Ruhrpumpen' column B from a row found by formula in col B:
=INDIRECT("Ruhrpumpen!B"&$B2)
Sheet 'Ruhrpumpen':
Column A: some data about a certain pump
Column B: some more data
Column I: pump codes. Beginning of the list includes defined name 'Pump_codes' used by the formula in column B of the main sheet.
Spreadsheet example: http://www.bumpclub.ee/~jyri_r/Excel/Data_from_other_sheet_by_code_row.xls
Guys Its very interesting to know that many of us face the problem of replication of lookup value while using the Vlookup/Index with Match or Hlookup.... If we have duplicate value in a cell we all know, Vlookup will pick up against the first item would be matching in loopkup array....So here is solution for you all...
e.g.
in Column A we have field called company....
Column A Column B Column C
Company_Name Value
Monster 25000
Naukri 30000
WNS 80000
American Express 40000
Bank of America 50000
Alcatel Lucent 35000
Google 75000
Microsoft 60000
Monster 35000
Bank of America 15000
Now if you lookup the above dataset, you would see the duplicity is in Company Name at Row No# 10 & 11. So if you put the vlookup, the data will be picking up which comes first..But if you use the below formula, you can make your lookup value Unique and can pick any data easily without having any dispute or facing any problem
Put the formula in C2.........A2&"_"&COUNTIF(A2:$A$2,A2)..........Result will be Monster_1 for first line item and for row no 10 & 11.....Monster_2, Bank of America_2 respectively....Here you go now you have the unique value so now you can pick any data easily now..
Cheers!!!
Anil Dhawan

Resources