Home > Back-end >  Is there a Within Formula somewhere?
Is there a Within Formula somewhere?

Time:11-13

I am trying to determine if there is a specific string of data in a cell. so if have a cell that says 1 2 3 4 5 6. Using the Space as a delimiter. is there a way for me to query the 4 out of it? and get a return of the 4?

I have tried using search and find but thats are just giving me the len position within the cell.

CodePudding user response:

I've setup my sheet like so:

An excel sheet with the numbers "1 2 3 4 5 6" in cell A2, the number 4 in cell B2, and the formula `MID(A2,SEARCH("4",A2,1)) in cell B1

The formula works like so:

mid(A2,                  //grab a substring from the middle of A2
       SEARCH("4",A2)    //find the value "4" inside A2
                     ,1) //make MID grab exactly one character (length of string "4"

With some jimmying, you can generalize this however you want.

CodePudding user response:

So, use find(), which you say you did but did not show how...

What about:

=if(iferror(find(A1,B1,1),0)>0,A1,"Not found")

enter image description here

CodePudding user response:

try:

=REGEXEXTRACT(A1&""; "\b4")

CodePudding user response:

Another solution for Google Sheets:

=if(iserror(MATCH(A1,SPLIT(B1," "),0)),"",A1)

(aka: look for A1 in B1) enjoy

  • Related