Extract text from a string in excel - excel

I want to extract the Test #. and the description that follows into two different columns side by side. Currently I have one long string. I want to break the string into two sets and extract only the needed information.
I have attached a screenshot to make it more clear. In the past I have used the MID function and FIND to extract text from strings, but since the strings here vary in length and content I'm not sure how to do this.
Thank you in advance!!

Formula for cell A9:
= LEFT(A2,FIND(".",A2)-1)
Formula for cell B9:
= MID(A2,FIND(". ",A2)+2,FIND(" .",A2)-FIND(". ",A2)-2)
Drag formulas down as far as necessary.

Related

How do i move or exctract number portions from a cell to another in excel

I would like to move numbers from one cell to another, or in some way extract numbers from one cell to another, with the number being removed from its previous cell.
Picture of how i want the data to be presented
Try:
Formula in B1:
=--CONCAT(IFERROR(--MID(A1,SEQUENCE(LEN(A1)),1),""))
Or, in case you have values like Test1 Test2 123456:
=--LET(a,TEXTSPLIT(A1," "),FILTER(a,ISNUMBER(--a)))
EDIT: The question is not solely about moving numbers but about presenting input without the number and the number seperately. Therefor try:
Formula in C1:
=LET(a,TEXTSPLIT(A1," "),HSTACK(TEXTJOIN(" ",,FILTER(a,ISERROR(--a))),--FILTER(a,ISNUMBER(--a))))
I would suggest to use FILTERXML() to extract numeric nodes.
=TRANSPOSE(FILTERXML("<t><s>"&SUBSTITUTE(A1," ","</s><s>")&"</s></t>","//s[number()=.]"))
Here "<t><s>"&SUBSTITUTE(A1," ","</s><s>")&"</s></t>" will construct a valid xml string.
FILTERXML() will process that xml string and xPath parameter //s[number()=.] will return only numeric nodes.
To know more about FILTERXML() read this post by #JvdV.

Extract text between two characters multiple times on multiple lines in Excel

I want to find an easy way to extract text between characters multiple times within the same cell. So in the example below, I want to take the information between the parenthesis and get them into the adjacent column, as shown. Is there a fast way to do this?
My process has been to use Text to Columns to separate them out into different cells, then use a mid function to get what's between the parenthesis, and string them all back together. I'm wondering if someone can think of a better way to do this. Thank you!
I should note-- I want to do this entirely within excel.
For example:
Formula in B1:
=TEXTJOIN(CHAR(10),1,LEFT(FILTERXML("<t><s>"&SUBSTITUTE(SUBSTITUTE(A1," (",CHAR(10)),CHAR(10),"</s><s>")&"</s></t>","//s[substring(.,1,3)*0=0]"),3))
Enter as array!
If you are interested in FILTERXML, you might want to have a look at this.
Assuming the 1st data is in A1, put :
=REPLACE(A1,1,FIND("(",A1),"") in C1
then,
=IFERROR(REPLACE(C1,FIND(")",C1),FIND("(",C1)-FIND(")",C1)+1," "),C1) in D1
and drag D1 to Q1. lastly, put
=Q1 in B1.
That shall do it.
Idea : replace all text between the ) & ( with a space, 15 times.
hope it helps.

How to extract a value that does not contain the string "None" in Excel?

I have 3 columns in my table and need to extract the one that does not contain the word "None".
Example:
Please help me with VBA code in which I can just extract the value into column1.
Since your question is tagged as excel-formula as well I offer you a formula based solution:
=CONCATENATE(IF(A1="none","",A1),IF(B1="none","",B1),IF(C1="none","",C1))
It connects texts of all of the needed cells but ignores cells with "none" in them, pretty straight-forward.

How to create a new string according to a user's input string

Excel experts, How can I create a new string according to a user's input string
Say in one cell, user input a string '15324', and the mapping rule is:
'1'->'A'
'2'->'B'
'3'->'C'
'4'->'D'
'5'->'E'
How to automatically generate 'AECBD' in target cell.
It will be best if we only use EXCEL's functions and no VBA or other scripts.
Thank you very much in advance.
This is a solution that will only work in Google Sheets, so doesn't achieve your preference of working in Excel as well.
Assumes your lookup table is in C:D (although that table may be hardcoded into the formula if you wish). Will return an #N/A error if any character is not found in that lookup table.
=ArrayFormula(CONCATENATE(VLOOKUP(MID(A1,ROW(OFFSET($A$1,,,LEN(A1),1)),1),C:D&"",2,0)))
Note: the $A$1 in the formula must stay as that reference (or at least, a cell in row 1).
With no option to loop, any formula will carry a great deal of repetition.
To make the formula less wordy, create a named range, call it "Alphabet" and assign it the string value ="ABCDEFGHIJKLMNOPQSTUVWXYZ"
The following model can be extended to more characters. Input can be number or a string and can be five or less characters:
=MID(Alphabet,MID(A1,1,1),1)&
IF(LEN(A1)>=2,MID(Alphabet,MID(A1&"",2,1),1),"")&
IF(LEN(A1)>=3,MID(Alphabet,MID(A1&"",3,1),1),"")&
IF(LEN(A1)>=4,MID(Alphabet,MID(A1&"",4,1),1),"")&
IF(LEN(A1)>=5,MID(Alphabet,MID(A1&"",5,1),1),"")
You might try:
=CHAR(LEFT(A1,1)+64)&CHAR(MID(A1,2,1)+64)&CHAR(MID(A1,3,1)+64)&CHAR(MID(A1,4,1)+64)&CHAR(MID(A1,5,1)+64)
and extend to 8 characters if desired (and all are present).
If in A1 is the value: 1234332
The length of the string in A1 can be any.
Put in B1 the formula: =arrayformula(join("";char(mid(A1;row(offset($A$1;0;0;len(A1);1));1)+96)))

VLookup not returning the results

I'm not sure why my VLOOKUP formula is not working like the screenshot below. The value is right there as highlighted. I want to output the value in Column G, but changing the 3rd parameter to 1 or 2 doesn't work.
Help is appreciated. Thanks much in advance.
Formula: =VLOOKUP(B2,$F$1:$G$421,2,FALSE)
One thing you may want to look at.
I notice your data is left justified and that's normally the case for textual rather than numeric fields - it's possible to left justify numerics but it's neither the default nor the general practice.
If they are textual, there's a chance one or more of them may have leading or trailing spaces. That would prevent the lookup from finding a match.
Select (in turn) B2 and F1 and use the arrow keys in the formula box to check this is not the case.
In cases like this, I tend to (temporarily) set B2 to the formula =F1 just to see if it can find a match that's guaranteed (then use CTRL-Z to revert).
If that change results in the lookup working then obviously the (original) B2 and F1 are not the same value, and you need to work out why (hidden spaces, wrong types, and so on).
It looks like you are comparing text to number (see the green triangle in your value cell). You have to convert the value in your source cell or matching cells to same type. To convert source to number use excel function such as int or value. Hope this helps.
Another way to convert text to number format is to multiply by 1 and then replace original text values with these new number values...
If you are doing lookup where you have a mix of text and numbers (i.e. looking up a text version of a number in a list of real numbers) you can also make use of the VALUE function... this will convert numbers stored as text to real numbers.
Embed it like so:
=VLOOKUP(VALUE(B2),$F$1:$G$421,1,FALSE)
If you have a mix of text numbers and text text to look up in numbers/text then you can do:
=VLOOKUP(IFERROR(VALUE(B2),B2),$F$1:$G$421,1,FALSE)
to change numbers stored as text to numbers, but leave other text as is...

Resources