I am trying to extract a string from a cell and I am running into some trouble. In this example I am looking to extract the string ARM52CVA from
A18031600473 ( FLORENCE - ARM52CVA )
Ive tried this formula and it doesnt seem to work for me
=RIGHT(C3,SEARCH("-",C3))
You would have come closer with either of:
=RIGHT(C3,LEN(C3)- SEARCH("-",C3))
=MID(C3,FIND("-",C3)+2,99)
but they would have left the ending.
If your data is exactly as you show it, with all of the data and spaces as shown, then try:
=INDEX(TRIM(MID(SUBSTITUTE(C3," ",REPT(" ",99)),{1,99,198,297,396},99)),5)
If there is more variability, you'll need to show more data.
Try,
=REPLACE(REPLACE(A1, 1, FIND("- ", A1)+1, ""), FIND(" ", REPLACE(A1, 1, FIND("- ", A1)+1, "")), LEN(A1), "")
The methods above are far more reliable but if the white space is consistent you can also use
=MID(A1,FIND("-",A1,1)+2,(FIND(")",A1,1)-3-FIND("-",A1,1)+1))
Related
This is related this question. The OP proposed to give inputs to a formula that contain a list of connection quantities and speeds like this:
1x1000,2x200,1x50 would mean that there is one 1000k connection, two 200k and 1 50k. I would like to parse this into an array table like this:
1
1000
2
200
1
50
I tried this formula, but it only produces the left hand side of the table:
=LET( case, A5,
a, FILTERXML("<t><s>"&SUBSTITUTE(case,",","</s><s>")&"</s></t>","//s[contains(., 'x')]"),
FILTERXML("<t><s>"&SUBSTITUTE(a,"x","</s><s>")&"</s></t>","//s") )
where case is the input variable, a parses the table into strings containing "x" (this is to ensure that only valid "q x speed" strings are used. I then tried to split this array and... no joy.
From this post by JvdV, I think the answer can be found in the xpath, but I cannot find a solution.
Looks like you want to either spill the entire array or use it in later calculations? Either way, I came up with:
=LET(X,FILTERXML("<t><s>"&SUBSTITUTE(SUBSTITUTE(A1,",","x"),"x","</s><s>")&"</s></t>","//s"),INDEX(X,SEQUENCE(COUNT(X)/2,2)))
Or, a littel more verbose without LET():
=INDEX(FILTERXML("<t><s>"&SUBSTITUTE(SUBSTITUTE(A1,",","x"),"x","</s><s>")&"</s></t>","//s"),SEQUENCE(LEN(A1)-LEN(SUBSTITUTE(A1,"x","")),2))
One way to get it is something like
=LET(x, FILTERXML("<t><s>"&SUBSTITUTE($A$1, ",", "</s><s>")&"</s></t>", "//s"),
IF(SEQUENCE(1,2)=1, LEFT(x, SEARCH("x",x)-1), RIGHT(x, LEN(x)-SEARCH("x",x))))
Once you break up the string by comma, you can then break up the component strings by "x" with something like
=TRANSPOSE(FILTERXML("<t><s>"&SUBSTITUTE(A7, "x", "</s><s>")&"</s></t>", "//s"))
but I'm not sure if you can combine the two actions in one go to get both width and depth dimensions (i.e. =TRANSPOSE(FILTERXML("<t><s>"&SUBSTITUTE(original_filterxml, "x", "</s><s>")&"</s></t>", "//s")) will not work).
Maybe,
In C1, formula copied right to D1 and all copied down :
=TRIM(MID(SUBSTITUTE(SUBSTITUTE(","&$A$1,"X",","),",",REPT(" ",99)),((ROW(A1)*2+COLUMN(A1))-2)*99,99))
Or,
If using FILTERXML function, try :
=IFERROR(FILTERXML("<a><b>"&SUBSTITUTE(SUBSTITUTE($A$1,"X",","),",","</b><b>")&"</b></a>","//b["&(ROW(A1)*2+COLUMN(A1))-2&"]"),"")
I have the below formula
=IF(D3="","",IFERROR(INDEX('Project Scoring'!$O$5:$O$1145,MATCH(D3&"*",'Project Scoring'!$D$5:$D$1145, 0)), " "))
I'd like to know the best way about going about adding 6 nested substitutes on the cell this formula will be used. Essentially I will be replacing what is Index/Matched with a char rather than the full string.
=SUBSTITUTE(SUBSTITUTE(IF(D5="","",IFERROR(INDEX('Project Scoring'!$O$5:$O$1145,MATCH(D5&"*",'Project Scoring'!$D$5:$D$1145, 0)), " ")), "Efficiency", "E"), "Compl/Risk/Legal", "R")
This is my excel data
As you can see in B2, this formula only search for the first text it found and will ignore the rest.
What I'm trying to accomplish is if 2 or more different texts are found like B2, is it possible to print another message ... let say Apple & Banana found
This is my original excel formula for your reference:
=IF(ISNUMBER(SEARCH("apple",A2)),"Apple",
IF(ISNUMBER(SEARCH("banana",A2)),"Banana",
IF(ISNUMBER(SEARCH("cher",A2)),"Cherries",
"Other")))
I have tried and tried and thought hmmm why don't I simply add a SUBSTITUTE function...and it worked ;o)
Just in case there is someone out there looking for this:
=SUBSTITUTE(TRIM(CONCATENATE(IF(ISNUMBER(SEARCH("apple",A2)),"Apple "," "),
IF(ISNUMBER(SEARCH("banana",A2)),"Banana "," "),
IF(ISNUMBER(SEARCH("cher",A2)),"Cherries "," "),
IF(SUM((ISNUMBER(SEARCH({"apple","banana","cher"},A2,1)))+0)=0,"Other "," "))),"Apple Banana","Both")
See if following formula tweak helps you:
=TRIM(CONCATENATE(IF(ISNUMBER(SEARCH("apple",A2)),"Apple "," "),
IF(ISNUMBER(SEARCH("banana",A2)),"Banana "," "),
IF(ISNUMBER(SEARCH("cher",A2)),"Cherries "," "),
IF(SUM((ISNUMBER(SEARCH({"apple","banana","cher"},A2,1)))+0)=0,"Other "," ")))&" found"
Here is my proposal :
You create a Table with your KeyWord and Result in two columns
(columns K for KeyWord and L for Result).
You change your formula like this
=IF(ISNUMBER(SEARCH(K2,A2)),L2, IF(ISNUMBER(SEARCH(K3,A2)),L3, IF(ISNUMBER(SEARCH(K4,A2)),L4, "Other")))
After that, is more easy to add new KeyWord, to change the order if you want to prioritize a KeyWord more than an other.
You can't use more than 63 KeyWords, but you can create a second formula from 64 to 126.
I have two strings, i want to extract the number in the middle "2200" i am using the formula
=VALUE(MID(C3,SEARCH("_",C3)+11,4))
C3 is where the string is. this formula working on "string 2" and give me the value i am looking for "2200" but doesn't work for "String 1" i get #VALUE!. if i change the formula
=VALUE(MID(C3,SEARCH("_",C3)+10,4))
it works for "String 1" but doesn't work for "String 2" How can i have same formula work in both situations?
String 1: ABC_1A1B_33C_2200_4AB_ABC4_4800
String 2: ABC_10A1B_33C_2200_4AB_ABC4_4800
thx,
This should work as long as the example 2200 is always 4 digits long:
=LEFT(REPLACE(D7,1,FIND("#",SUBSTITUTE(D7,"_","#",3)),""),4)
If the value you wish to extract is always in the fourth position, then you can try:
=INDEX(TRIM(MID(SUBSTITUTE(C3,"_",REPT(" ",99)),seq_99,99)),4,1)
where seq_99 is a Named Formula that refers to:
=IF(ROW(INDEX(Sheet1!$1:$65535,1,1):INDEX(Sheet1!$1:$65535,255,1))=1,1,(ROW(INDEX(Sheet1!$1:$65535,1,1):INDEX(Sheet1!$1:$65535,255,1))-1)*99)
seq_99 will return an array: {1,99,198,297,...,25146}
This does not care as to the length, only that it is the forth block:
=TRIM(MID(SUBSTITUTE(A1,"_",REPT(" ", 999)),3*999,999))
Note
The above returns a text string that looks like a number. If a number is what is wanted then replace the TRIM with --
=--MID(SUBSTITUTE(A1,"_",REPT(" ", 999)),3*999,999)
This solution is based on the static position of the number being between the third and fourth underscore character.
=--TRIM(MID(SUBSTITUTE(SUBSTITUTE(A2, "_", REPT(" ", LEN(A2)), 4), "_", REPT(" ", LEN(A2)), 3), LEN(A2), LEN(A2)))
Note the double-unary (aka double-minus or --) that converts text-that-looks-like-a-number to a true number.
I have a set of data that shown below on excel.
R/V(208,0,32) YR/V(255,156,0) Y/V(255,217,0)
R/S(184,28,16) YR/S(216,128,0) Y/S(209,171,0)
R/B(255,88,80) YR/B(255,168,40) Y/B(255,216,40)
And I want to separate the data in each cell look like this.
R/V 208 0 32
R/S 184 28 16
R/B 255 88 80
what is the function in excel that I can use for this case.
Thank you in advance.
kennytm doesn't provide an example so here's how you do substrings:
=MID(text, start_num, char_num)
Let's say cell A1 is Hello.
=MID(A1, 2, 3)
Would return
ell
Because it says to start at character 2, e, and to return 3 characters.
In Excel, the substring function is called MID function, and indexOf is called FIND for case-sensitive location and SEARCH function for non-case-sensitive location. For the first portion of your text parsing the LEFT function may also be useful.
See all the text functions here: Text Functions (reference).
Full worksheet function reference lists available at:
Excel functions (by category)
Excel functions (alphabetical)
Another way you can do this is by using the substitute function. Substitute "(", ")" and "," with spaces.
e.g.
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1, "(", " "), ")", " "), ",", " ")
I believe we can start from basic to achieve desired result.
For example, I had a situation to extract data after "/". The given excel field had a value of 2rko6xyda14gdl7/VEERABABU%20MATCHA%20IN131621.jpg . I simply wanted to extract the text from "I5" cell after slash symbol. So firstly I want to find where "/" symbol is (FIND("/",I5). This gives me the position of "/". Then I should know the length of text, which i can get by LEN(I5).so total length minus the position of "/" . which is LEN(I5)-(FIND("/",I5)) . This will first find the "/" position and then get me the total text that needs to be extracted.
The RIGHT function is RIGHT(I5,12) will simply extract all the values of last 12 digits starting from right most character. So I will replace the above function "LEN(I5)-(FIND("/",I5))" for 12 number in the RIGHT function to get me dynamically the number of characters I need to extract in any given cell and my solution is presented as given below
The approach was
=RIGHT(I5,LEN(I5)-(FIND("/",I5))) will give me out as VEERABABU%20MATCHA%20IN131621.jpg . I think I am clear.
Update on 11/30/2022
With new excel functions, you can use the following in cell C1 for the input in A1:
=TEXTJOIN(" ",,TEXTSPLIT(A1,{"(",",",")"}))
Here is the output:
What about using Replace all?
Just replace All on bracket to space.
And comma to space. And I think you can achieve it.