Excel: Using text functions to find the middle - excel

I want to extract Moss Ariel and Murphy from the following strings using text functions in Excel.
Gabriela Moss669.11695-5000-53420000000-1232
Connie Ariel1025.11695-2004-51490000000-1231
Kelly Murphy1040.58695-2200-50630000000-1235
I have a basic grasp with using text functions, but this one has stumped me. Any help is greatly appreciated.
I need to make a formula such that it requires no changes copying it down the list of records.

This would be easier and shorter in Google Sheets or with VBA UDF, but here is another array formula solution (enter it with Ctrl + Shift + Enter) from https://exceljet.net/formula/split-text-and-numbers
=MID(A1,FIND(" ",A1)+1,MIN(FIND(ROW($1:$10)-1,A1&"0123456789"))-FIND(" ",A1)-1)
This might work without array formula:
=MID(A1,FIND(" ",A1)+1,MIN(FIND({0,1,2,3,4,5,6,7,8,9,"."},A1))-FIND(" ",A1)-1)

Say you data begins in A1
First extract the full name with the following formula
[B1] = {LEFT(A1,MATCH(1,--ISNUMBER(--MID(A1,ROW(INDIRECT("A1:A"&LEN(A1))),1)),0)-1)}
This is an array formula, press Ctrl+Shift+Enter after typing formula in B1. Then fill down the formula to the rest of the rows.
Next, simply extract the last name from the full name
[C1] = RIGHT(B1,LEN(B1)-SEARCH(" ",B1))
If you prefer to do it in-one-go here is the formula
[B1] = {MID(A1,SEARCH(" ",A1)+1,MATCH(1,--ISNUMBER(--MID(A1,ROW(INDIRECT("A1:A"&LEN(A1))),1)),0)-1-SEARCH(" ",A1))}

You can use the below formula as it is, no need for array formula to achieve this.
=MID(A1,SEARCH(" ",A1,1)+1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&"0123456789"))-SEARCH(" ",A1,1)-1)

You need to combine the functions instr and mid. instr returns the index in a string of the first appearance of a sub-string (or a single character). mid returns a sub-string starting at a given position and with a length of the extracted sub-string. In your case, something like:
MID(MyString,Index(MyString,"Moss"),Len("Moss"))
where MyString holds your source string.

Related

Using Excel formulas compare 2 columns and match if there is a substring

Struggling to do this in Python so trying Excel formula.
these are the logic steps I would like to do:
Convert both columns to lowercase
if keyword matches any cell/s in the data string data string then identify the keyword and data string match and and put in another cell.
If there are no matches for the keyword then can put not found
How can I do this?
input example below: (as you can see data strings can be in any order)
output example:
output example:
Thank you!
Based on your revisions...
You will need to type the correct value for d2. Then in d3 and going down, you can use this formula.
=IF(OR(SUM(--ISNUMBER(FIND(D2,$B$2:$B$7)))=COUNTIFS($D$1:D2,D2),SUM(--ISNUMBER(FIND(D2,$B$2:$B$7)))=0),INDEX($A$2:$A$7,MATCH(D2,$A$2:$A$7,0)+1),D2)
Then in e2 and going down, you can use this formula
=IFERROR(INDEX($B$2:$B$7,SMALL(IF(ISNUMBER(FIND(LOWER(D2),LOWER($B$2:$B$7))),ISNUMBER(FIND(LOWER(D2),LOWER($B$2:$B$7)))*ROW($B$2:$B$7)-1),COUNTIFS($D$1:D1,D2)+1)),"not found")
Remember to enter both of the formulas with control + shift + enter

Search an array for a text string in a separate array, return that text string (Excel)

I have a column of text values (column C below), they are of varying length. I have a separate array of text values (column A below). I want a formula that will look through the strings in Column C and return the word from Column A that it matches. If there are multiple matches (rare, probably won't happen), it will only return one.
Please see my example:
Column D is the result I am looking for. As you can see, this will require some kind of fuzzy string matching. The word could appear anywhere in the cell. It doesn't need to be case sensitive. But I need it to pull that word out of the string as the result basically.
Thank you!
Use This:
=INDEX(A:A,AGGREGATE(15,6,ROW($A$2:$A$5)/(ISNUMBER(SEARCH($A$2:$A$5,C2))),1))
One more, slightly simpler:
=IF(COUNTIF($C$1:$C$100," * "&A2&" * ")>0,A2,"")
You can also try this formula =INDEX(A:A,SUMPRODUCT(MATCH(1,NOT(ISERR(SEARCH(A:A,C2)))*1,0))). Enter it using CTRL+SHIFT+ENTER since it is an array formula.
This formula seems to be working for me:
(Please use Ctrl+Shift+Enter for the array formula to take effect)
{=INDEX($A$2:$A$5,MATCH(1,COUNTIF(C2,"*"&$A$2:$A$5&"*"),0))}
Screenshot of Excel sheet

Extract substring from this string inside Excel cell

I have this Excel cell A2 with the contents USD.EUR[IDEALPRO,CASH,EUR].
I would like to extract the substring EUR from the last part of the string using an Excel formula. The nearest formula I came out with is =RIGHT(A2,4). However, it returns EUR].
What formula can be used to extract the substring?
I am using MS Excel 2013.
If the string that you are searching is only 3 bytes in length, then your simple formula works. But what if it changes? Try the below,
=MID(SUBSTITUTE(F2,",","#",LEN(F2)-LEN(SUBSTITUTE(F2,",",""))),FIND("#",SUBSTITUTE(F2,",","#",LEN(F2)-LEN(SUBSTITUTE(F2,",",""))))+1,FIND("]",SUBSTITUTE(F2,",","#",LEN(F2)-LEN(SUBSTITUTE(F2,",",""))))-FIND("#",SUBSTITUTE(F2,",","#",LEN(F2)-LEN(SUBSTITUTE(F2,",",""))))-1)
Where F2 is your string. This formula unstrings the string between the last delimiter "," and "]". This is too complicated but it might help you.
I will answer my own question. It has been tested to work.
=SUBSTITUTE(RIGHT(A2,4),"]","")
RIGHT(A2,4) returns EUR]. Afterwards, use SUBSTITUTE to remove ].
You can use a combination of MID and REVERSETEXT functions.
Formula
=REVERSETEXT(MID(REVERSETEXT(A1), 2, 3))
Otherwise, if the length is unknown for the part which you want to retrieve. Then use FIND function to find the comma before that particular word.
=REVERSETEXT(MID(REVERSETEXT(A3), 2, FIND(",", REVERSETEXT(A3)) - 2))

Using Indirect function in CountIf formula to count the number of times the text string occurs in a column

Hi and thank you in advance for your help.
I am trying to count the number of times a text string, for example "UML" occurs within a column. The column may contain the text by itself or it may contain the text(UML) in a list with other text(UML,SAS,Excel). I need to be able to count it even if it's within a list. I understand using two * on each side of the text string will work if I write it out but I don't want to write it over and over again.
I am open to alternatives other than countif formula but if there is a way to do it with countif would you please share both.
Thanks again for your help!
If column F contains your lookup value, and it's contained in square brackets, then building on your formula I'd use:
=COUNTIF($A$1:$A$4247,SUBSTITUTE(SUBSTITUTE("*" & F2 & "*","[",""),"]",""))
We substitute the square brackets for nothing, to remove them on the fly from the lookup value. Then we search the strings, basically for *UML*. And this formula is draggable downable (F2 will move with you). Is this what you need?
Just to put my two cents in:
The formula to count column A on what is entered in F2 is:
=Countif(A:A,"*" & F2 & "*")

Nested IFs in function not working

Hi, I'm trying to input a function in C2 in order to assign a numerical value to the minutes given in Column B. The criteria for this can be seen in the image above (starting at G1).
I have tried using a formula I copied from a similar situation but is not working:
=IF(B2<=$A$2,5,IF(B2<=$A$3,4,IF(B2<=$A$4,3,IF(B2<=$A$5,2,1))))
Any help would be appreciated, thanks
The suggestion by #Jeeped above will simplify the formulas needed. If you have to keep the 'A' and 'B' cells as they are listed above, you have to extract the number from the 'x min' format and convert the 'x' to a number so it can be compared (I assume a " " exists after the number. Could search for " min" as well).
=VALUE(LEFT(A2,SEARCH(" ",A2)-1))
Using the above, if A2 = '60 min', the formula will produce a '60'.
Now that the cell contents can be treated as numbers, the comparisons can be made. Formula for C2:
=IF(VALUE(LEFT(B2,SEARCH(" ",B2)-1))<=VALUE(LEFT($A$2,SEARCH(" ",$A$2)-1)),5,
IF(VALUE(LEFT(B2,SEARCH(" ",B2)-1))<=VALUE(LEFT($A$3,SEARCH(" ",$A$3)-1)),4,
IF(VALUE(LEFT(B2,SEARCH(" ",B2)-1))<=VALUE(LEFT($A$4,SEARCH(" ",$A$4)-1)),3,
IF(VALUE(LEFT(B2,SEARCH(" ",B2)-1))<=VALUE(LEFT($A$5,SEARCH(" ",$A$5)-1)),2,1))))
This is ugly, but works given the original question.
Try this formula (in this case for C2):
=SUM((B2<=$A$2:$A$5)*1)+1
It is important to use it as array formula. So after typing or inserting this formula to your cell don't just commit with Return but hit Ctrl+Shift+Return. If you did it right, your formula will be surrounded by curly brackets in formula bar:
{=SUM((B2<=$A$2:$A$5)*1)+1}

Resources