Excel - Can't Extract Partial String via known formulas - excel

I know this has been beaten to death but I cannot get mine to work for the below example:
%B1234567^SMITH/MIKE^ABC123DEF456?;1234567=0111000?
A1 contains the above text data and I am trying to copy the string between "%B" and the first "^".
I tried:
=mid(left(A1,find("%B",A1)-1),find("^",A1)+1,len(A1))
But no data appears in B1 (where the formula is placed).
Any suggestions?
Thanks, Brendan

You could use:
Formula in B1:
=MID(A1,FIND("%B",A1)+2,FIND("^",A1,FIND("%B",A1))-FIND("%B",A1)-2)

Just tested this and try:
=mid(A1,find("B",A1,1)+1,6)*1
You can then incorporate the extra code to find the caret if needed, as I assumed 7 digits or characters. To get the result recognized as a number multiply by 1.
Just don't use the %

This worked for me.
MID(A1,FIND("%B",A1)+2,FIND("^",A1)-FIND("%B",A1)-2)

Related

Extract information before several special characters in excel

I have a problem with an excel file.
I am trying to extract information from a column. This information appears randomly, before a ".", "-" or ":". So an example would be:
CELL
EXPECTED RESULT
hi.this is:
hi
maybe I- this works
maybe I
Who is: what. like-
Who is
I am using the formula:
=MID(A1,1,FIND("-",A1,1)-1)
Using this one, I get the information I need, but I am not able to add the other characters (".", ":",...) to the formula. Also I have the problem that in a same cell, I can have several of this characters, and I only want the information before the FIRST character (of all posible kinds) that appears in the cell.
I dont know if somebody can help me here.
Thank you very much in advance!
You can try:
Formula in B1:
=TEXTBEFORE(A1:A3,{".","-",":"})
If you don't yet have acces to TEXTBEFORE() then try:
=LEFT(A1,MIN(FIND({".","-",":"},A1&".-:"))-1)
I suppose this is an array-entered formula in versions prior to ms365.

How To Extract The CAPITAL WORDS or BLOCK LETTER WORDS From A String In Excel

How to extract the capitalized full words from a string in excel ? Refer the first Image, I have used the following formula to extract the CAPITAL / BLOCK LETTER WORDS From a string in a cell, it works perfectly,
• Formula used in cell B2
=TEXTJOIN(" ",,
FILTERXML("<a><b>"&SUBSTITUTE(A2," ","</b><b>")
&"</b></a>","//b[translate(.,'abcdefghijklmnopqrstuvwxyz',
'ABCDEFGHIJKLMNOPQRSTUVWXYZ')=.]"))
The above formula works perfectly as longs as there is no numerical, but it doesn't give proper output when there are some numbers, refer the Image below, may be I am missing something, using O365
Refer the cells those green colored backgrounds, it should bring only the CAPITAL WORDS but it carries also the numbers. What should be the right way here. Thank You!
Courtesy : I have learnt & used FILTERXML formula by following the post of JvdV Sir, and it really helped me a lot, Thank you very much Sir for this wonderful piece.!
Workbook_OneDrive_Link
As per the given sample data:
=TEXTJOIN(" ",,FILTERXML("<t><s>"&SUBSTITUTE(A2," ","</s><s>")&"</s></t>","//s[translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', '')='']"))
This would check when all uppercase alpha-chars are translated to nothing the node would equal nothing, meaning all characters were uppercase alpha.

Regular Expressions [duplicate]

How to extract the capitalized full words from a string in excel ? Refer the first Image, I have used the following formula to extract the CAPITAL / BLOCK LETTER WORDS From a string in a cell, it works perfectly,
• Formula used in cell B2
=TEXTJOIN(" ",,
FILTERXML("<a><b>"&SUBSTITUTE(A2," ","</b><b>")
&"</b></a>","//b[translate(.,'abcdefghijklmnopqrstuvwxyz',
'ABCDEFGHIJKLMNOPQRSTUVWXYZ')=.]"))
The above formula works perfectly as longs as there is no numerical, but it doesn't give proper output when there are some numbers, refer the Image below, may be I am missing something, using O365
Refer the cells those green colored backgrounds, it should bring only the CAPITAL WORDS but it carries also the numbers. What should be the right way here. Thank You!
Courtesy : I have learnt & used FILTERXML formula by following the post of JvdV Sir, and it really helped me a lot, Thank you very much Sir for this wonderful piece.!
Workbook_OneDrive_Link
As per the given sample data:
=TEXTJOIN(" ",,FILTERXML("<t><s>"&SUBSTITUTE(A2," ","</s><s>")&"</s></t>","//s[translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', '')='']"))
This would check when all uppercase alpha-chars are translated to nothing the node would equal nothing, meaning all characters were uppercase alpha.

Comparing comma separated alphanumeric characters in cells

Original Question
Please refer to the original question above. I was told to ask a new question.
Ron Rosenfeld's solution works great on numbers but how would the formula change if my two lists are alphanumeric e.g. P1234,C4321,P0123,P0678?
Formula:
=TEXTJOIN(",",TRUE,IFERROR(1/(1/(ISNUMBER(FIND(","&TRIM(MID(SUBSTITUTE(B2,",",REPT(" ",99)),seq_99,99))&",",","&A2&","))))*TRIM(MID(SUBSTITUTE(B2,",",REPT(" ",99)),seq_99,99)),""))
Before the second TRIM, if I just add "0"& the results work but each has a 0 before it. For example:
))))*"0"&TRIM(MID(SUBSTITUTE
Results in something like 0C4321,0P0123,0P0678.
It can be modified as such:
=TEXTJOIN(",",TRUE,IF(ISNUMBER(FIND(","&TRIM(MID(SUBSTITUTE(B1,",",REPT(" ",99)),seq_99,99))&",",","&A1&",")),TRIM(MID(SUBSTITUTE(B1,",",REPT(" ",99)),seq_99,99)),""))
But there is a shorter version that does not require the named range.
=TEXTJOIN(",",TRUE,FILTERXML("<a><b>"&SUBSTITUTE(B2,",","</b><b>")&"</b></a>","//b[contains(',"&A2&",',concat(',', ., ','))]"))
Depending on one's version these may need to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.
You could try:
Formula in C1:
=TEXTJOIN(",",,FILTERXML("<t><s>"&SUBSTITUTE(A1&","&B1,",","</s><s>")&"</s></t>","//s[preceding::*=.]"))

Turn '=IF(ISNUMBER(SEARCH')' answer into numeric instead of text (to use autosum)

I'm trying to get Excel to work out if a cell contains a certain courier company (DHL, DPD etc) and I want it to give out the number of miles to the nearest drop-off point. It works but it gives me a text answer instead of a number, this means autosum won't work. How do I change the code to give a numeric answer? Cheers Brian
=IF(
ISNUMBER(SEARCH("collect",Q2,1))=TRUE,"1",
IF(ISNUMBER(SEARCH("dhl",Q2,1))=TRUE,"2.6",
IF(ISNUMBER(SEARCH("DPD",Q2,1))=TRUE,"1",
IF(ISNUMBER(SEARCH("inpost",Q2,1))=TRUE,"1.2",
IF(ISNUMBER(SEARCH("hermes",Q2,1))=TRUE,"0.6",
IF(ISNUMBER(SEARCH("royal",Q2,1))=TRUE,"0.5",
IF(ISNUMBER(SEARCH("force",Q2,1))=TRUE,"0.5",
IF(ISNUMBER(SEARCH("ups",Q2,1))=TRUE,"0.6",
IF(ISNUMBER(SEARCH("yodel",Q2,1))=TRUE,"0",
IF(ISNUMBER(SEARCH("collection",Q2,1))=TRUE,"0",
"No"))
=IF
(ISNUMBER(SEARCH("collection",Q2,0))=TRUE,1,
IF(ISNUMBER(SEARCH("dhl",Q2,1))=TRUE,2.6,
IF(ISNUMBER(SEARCH("DPD",Q2,1))=TRUE,1,
IF(ISNUMBER(SEARCH("inpost",Q2,1))=TRUE,1.2,
IF(ISNUMBER(SEARCH("hermes",Q2,1))=TRUE,0.6,
IF(ISNUMBER(SEARCH("royal",Q2,1))=TRUE,0.5,
IF(ISNUMBER(SEARCH("force",Q2,1))=TRUE,0.5,
IF(ISNUMBER(SEARCH("ups",Q2,1))=TRUE,0.6,
IF(ISNUMBER(SEARCH("yodel",Q2,1))=TRUE,0,
0))))))))
If I followed your question correctly, this should work.
It has the advantage that you can extend the list easily to add other transporters and update distances.
You could use index() with match() in cell B3 instead of vlookup if you wish:
=IFERROR(INDEX($E$5:$E$13,MATCH(A3,$D$5:$D$13,0)),"not in list")
I used data validation to pick from the list in cell A3.
I just copied your formula in accordance with the comments, and removed =TRUE:
=IF
(ISNUMBER(SEARCH("collection",Q2,1)),1,
IF(ISNUMBER(SEARCH("dhl",Q2,1)),2.6,
IF(ISNUMBER(SEARCH("DPD",Q2,1)),1,
IF(ISNUMBER(SEARCH("inpost",Q2,1)),1.2,
IF(ISNUMBER(SEARCH("hermes",Q2,1)),0.6,
IF(ISNUMBER(SEARCH("royal",Q2,1)),0.5,
IF(ISNUMBER(SEARCH("force",Q2,1)),0.5,
IF(ISNUMBER(SEARCH("ups",Q2,1)),0.6,
IF(ISNUMBER(SEARCH("yodel",Q2,1)),0,
0))))))))

Resources