search a string of numbers for a number

klatlap

Well-known Member
Joined
Sep 1, 2004
Messages
597
I have a string similar to this 1,9,7,11,8,10

I need a formula that would find 11 , the string can be different lengths so the number is not always in the same position.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

jtakw

Well-known Member
Joined
Jun 29, 2014
Messages
7,245
Office Version
  1. 2016
Platform
  1. Windows
Hi,

So what do you want happened (result) once the formula finds it in the Text string, and what if it isn't there ?
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
14,778
Office Version
  1. 2010
Platform
  1. Windows
But what do you want to result? a label that says "Yes it exists"

=IF(IFERROR(SEARCH("11",A1),0)=0,"Does not exist", "Yes it exists")
 
Last edited:

jtakw

Well-known Member
Joined
Jun 29, 2014
Messages
7,245
Office Version
  1. 2016
Platform
  1. Windows

ADVERTISEMENT

Use B1 formula if you want the value to look for (i.e. 11) hard-coded in the formula.
Use C1 formula if you might want to look for different values using a cell reference.


Book1
ABCDEF
11,9,7,11,8,10YesYesFind What11
21,9,111,7,11,8,10YesYes
31,9,111,7,112,8,10NoNo
411,9,7,110,8,10YesYes
51,9,7,211,8,10,11YesYes
Sheet586
Cell Formulas
RangeFormula
B1=IF(ISNUMBER(FIND(",11,",","&A1&",")),"Yes","No")
C1=IF(ISNUMBER(FIND(","&F$1&",",","&A1&",")),"Yes","No")


Formulas will Not error for 1, 111, 211, 112, etc., formula will Only result "Yes" if 11 exist within string.
 
Last edited:

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
14,778
Office Version
  1. 2010
Platform
  1. Windows

ADVERTISEMENT

so the above formula can see the difference between 11 and 1?



Try this:

=IF(IFERROR(SEARCH(",11,",A1),0)=0,"No", "Yes")
 

jtakw

Well-known Member
Joined
Jun 29, 2014
Messages
7,245
Office Version
  1. 2016
Platform
  1. Windows
@ DanteAmor, That won't work if the 11 is in the beginning or end of the string, you must Also include commas before and after the cell containing the string.
 
Last edited:

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
14,778
Office Version
  1. 2010
Platform
  1. Windows
@ DanteAmor, That won't work if the 11 is in the beginning or end of the string, you must Also include commas before and after the cell containing the string.

@jtakw, You're right

Use this:

=SI(SI.ERROR(HALLAR(",11,", ","&A1&","),0)=0,"No", "Yes")
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,713
Messages
5,833,269
Members
430,200
Latest member
ADLHMA2022

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
Top