Find exact match and partial within same cell

agoraotro

New Member
Joined
Sep 28, 2014
Messages
2
Hi everyone,

I've been struggling to find a way to use a single formula to look for a text within a cell and, in another case, an exact match in that same cell.

This is an example:

Case 1= if A1 contains "red apples, apples, pears, grapes", value is TRUE
Case 2= if A1 contains "red apples, pears, grapes", value is FALSE
Case 3= if A1 contains "apples", value is TRUE

I would like B1 to display "OK" when the value is true as shown in the cases above. I want the formula to state the value is true only when the item 'apples' is present in the cell, and not others like 'red apples'.

I have tried with these formulas so far:

=IF(OR(ISERROR(FIND("apple",A1,1))),"","OK")
will be fine for case 1 and 3, but not 2

=IF(OR(ISERROR(FIND("apple,",A1,1))),"","OK")
will be fine for case 1 and 2, but not 3

Any ideas?

Thanks in advance
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
agoraotro,

Welcome to MrExcel.

Does this cover all situations?

Excel 2007
AB
1red apples, apples, pears, grapesOK
2red apples, pears, grapes
3applesOK
4apples, grapes red applesOK
5pears, red apples
6pears
7pears, applesOK
8
Sheet1
Cell Formulas
RangeFormula
B1=IF(OR(A1="apples",LEFT(A1,7)="apples,",RIGHT(A1,8)=", apples"),"OK",IF(OR(ISERROR(FIND(", apples,",A1,1))),"","OK"))


Hope that helps.
 
Upvote 0
if A1 contains red apples apples you cannot distinguish between them, unless you know red onlyoccurs in front of apples....
 
Upvote 0
Just another option that you could try:

Excel Workbook
AB
1red apples, apples, pears, grapesOK
2red apples, pears, grapes
3applesOK
4apples, grapes red applesOK
5pears, red apples
6pears
7pears, applesOK
Sheet1
 
Upvote 0

Forum statistics

Threads
1,216,058
Messages
6,128,538
Members
449,456
Latest member
SammMcCandless

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