first-time poster so please bear with me. I am trying to convince Excel to do a substring and failing miserably. The task is simple enough on the surface of it, extract text that's between a fixed set of chars (+, -, * and /), basically mathematical operators.
My input string looks like this:
A+B+C+D
Now, if my string looks like that, or like A-B-C-D, all is good, I can use this and it works (not my code, found on https://exceljet.net/formula/split-text-with-delimiter and modified to suit my needs:
First text: TRIM(MID(SUBSTITUTE($A2,"+",REPT(" ",LEN($A2))),0*LEN($A2)+1,LEN($A2)))
Second: TRIM(MID(SUBSTITUTE($A2,"+",REPT(" ",LEN($A2))),1*LEN($A2)+1,LEN($A2)))
Third: TRIM(MID(SUBSTITUTE($A2,"+",REPT(" ",LEN($A2))),2*LEN($A2)+1,LEN($A2)))
Forth: TRIM(MID(SUBSTITUTE($A2,"+",REPT(" ",LEN($A2))),3*LEN($A2)+1,LEN($A2)))
And all is good, until I have a string like: A-B+C-D or wahtever combo, basically not all the same char.
I tried using Find and Search in different configurations, but I always come to the same problem:
Using substitute gives me the n'th occurance and that's no good as - may be my second symbol or third
Can't dynamically and accurately calculate the length for MID, as it does Nr. of chars, not "until"
I can't use VB script for security reasons, so I am stuck trying to use Excel formulas.
It HAS to be one formula, as in the end, it's part of a bigger formula that's something like this:
CONCATENATE(IF(ISNUMBER(A),A,VLOOKUP(A)),IF(ISNUMBER(A),A,VLOOKUP(A)),IF(ISNUMBER(A),A,VLOOKUP(A)),IF(ISNUMBER(A),A,VLOOKUP(A)))
So I have the input in a cell and my result has to do all the processing in an adjacent cell.
Thank you in advance, at whit's end over here.
You can try FILTERXML() function.
=TRANSPOSE(FILTERXML("<t><s>"&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"+","|"),"-","|"),"*","|"),"/","|"),"|","</s><s>")&"</s></t>","//s"))
If you are not on Excel365 then try below formula.
=FILTERXML("<t><s>"&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($A1,"+","|"),"-","|"),"*","|"),"/","|"),"|","</s><s>")&"</s></t>","//s[" & COLUMN(A1) &"]")
To learn FILTERXML() go through this article from #JvdV
For lower versions of Excel following formula would work by copying across as much as needed:
=TRIM(MID(SUBSTITUTE(" "&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($A1,"+"," "),"-"," "),"/"," "),"*"," ")," ",REPT(" ",99)),99*COLUMNS($A1:A1),99))
which is fairly similar to what has been posted on Exceljet site.
Related
I was surfing the net, looking for a solution on how to retrieve the number that I need from a string in Excel.
So I have this kinda string:
"somecharacterso=3242&morecharacters"
and I am trying to retrieve the "3242" number according to this https://www.ablebits.com/office-addins-blog/excel-regex-formulas/#functions
and stuck with this RegExp: o=\b(\d+)\b& but it extracts the full substring not the number only.
So, now tested and improved:
EDIT: based on comment to use "o=" and "&":
=MID(A1,FIND("o=",A1,1)+2,(FIND("&",A1,1)-FIND("o=",A1,1)-2))*1
Does exactly as asked.
=mid(A1,find("=",A1,1)+1,find("&",A1,1)-(find("=",A1,1)+1))*1
returns the 3242 as a number.
There's good style in Excel formulae as well as in programming languages, particularly for making the logic easily understandable to other people who use the file later.
So if the starting data is in A2:
In B2 put =FIND("o=",A2)
In C2 put =FIND("&",A2)
In D2 put =MID(A2,B2+2,C2-B2-2) * 1
Exactly the same logic as Solar Mike's answer, but for most people easier to follow, check, and amend if necessary in the future.
Formulae using native Excel functions (especially shortish ones) are understood by far more people than regex.
I have in (D2) very dirty string:
Ⱦ[ḫ]îs ɨs síṁƥḽẽ ~s?tring $with Ḑiă{cr}îtíc#s ẵɲd Ṧɏ<ṃƀǿⱡs. /123
To clean this I use two great formulas (Thanks #Jvdv)
First - Cleaning string from unwanted characters:
=TRIM(CONCAT(IF(MMULT(IFERROR(SEARCH("~"&MID(D2;ROW(X$1:INDEX(X:X;LEN(D2)));1);{"ÁÀȦÄǍĀÃÅĄȺẤẦẮẰǠǺǞẪẴẢȀȂẨẲẠḀẬẶĂÂḂɃƁḄḆĆĊĈČÇȻḈƇƆḊĎḐĐƊḌḒḎÐƉÉÈĖÊËĚĔĒẼĘȨɆẾỀḖḔỄḜẺȄȆỂẸḘḚỆÉÈÊËḞƑǴĠĜǦĞḠĢǤƓḢĤḦȞḨĦḤḪⱧÍÌÏǏĬĪĨĮƗḮỈȈȊỊḬÍÌÏÎĴḰǨĶƘḲḴⱩĹĿĽⱢⱠĻȽŁḶḼḺḸḾṀṂŃǸṄŇÑŅƝṆṊṈÑŊÓÒȮÔÖǑŎŌÕǪŐỐỒƟØṒṐṌȪỖṎǾȬǬỎȌȎƠỔỌỚỜỠỘỞỢÓÒÔÖÕṔṖⱣƤŔṘŘŖɌⱤȐȒṚṞṜŚṠŜŠṤṦṢṨŞȘṪŤƬṬȚƮṰṮȾŢŦ"\"ÚÙÛÜǓŬŪŨŮŲŰɄǗǛṸṺỦȔȖƯỤṲỨỪṶṴỮỬỰÚÙÛÜṼṾẂẀẆŴẄẈẊẌÝỲẎŶŸȲỸɎỶƳỴÝŹŻẐŽƵẒẔ /0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});0);{1;1});MID(D2;ROW(X$1:INDEX(X:X;LEN(D2)));1);" ")))
Only First formula return next:
Ⱦ ḫ îs ɨs síṁƥḽẽ s tring with Ḑiă cr îtíc s ẵɲd Ṧɏ ṃƀǿⱡs /123
Second - Converting diacritics to alphabetical:
=CONCAT(IFERROR(IF(EXACT(LOWER(MID(D2;ROW(X$1:INDEX(X:X;LEN(D2)));1));MID(D2;ROW(X$1:INDEX(X:X;LEN(D2)));1));LOWER(MID(CONCATENATE("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBCCCCCCCCCDDDDDDDDDDEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEFFGGGGGGGGGHHHHHHHHHIIIIIIIIIIIIIIIIIIIJKKKKKKKLLLLLLLLLLLLMMMNNNNNNNNNNNNOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOPPPPRRRRRRRRRRRSSSSSSSSSSTTTTTTTTTTT";"UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUVVWWWWWWXXYYYYYYYYYYYYZZZZZZZ");SEARCH("~"&MID(D2;ROW(X$1:INDEX(X:X;LEN(D2)));1);CONCATENATE("ÁÀȦÄǍĀÃÅĄȺẤẦẮẰǠǺǞẪẴẢȀȂẨẲẠḀẬẶĂÂḂɃƁḄḆĆĊĈČÇȻḈƇƆḊĎḐĐƊḌḒḎÐƉÉÈĖÊËĚĔĒẼĘȨɆẾỀḖḔỄḜẺȄȆỂẸḘḚỆÉÈÊËḞƑǴĠĜǦĞḠĢǤƓḢĤḦȞḨĦḤḪⱧÍÌÏǏĬĪĨĮƗḮỈȈȊỊḬÍÌÏÎĴḰǨĶƘḲḴⱩĹĿĽⱢⱠĻȽŁḶḼḺḸḾṀṂŃǸṄŇÑŅƝṆṊṈÑŊÓÒȮÔÖǑŎŌÕǪŐỐỒƟØṒṐṌȪỖṎǾȬǬỎȌȎƠỔỌỚỜỠỘỞỢÓÒÔÖÕṔṖⱣƤŔṘŘŖɌⱤȐȒṚṞṜŚṠŜŠṤṦṢṨŞȘṪŤƬṬȚƮṰṮȾŢŦ";"ÚÙÛÜǓŬŪŨŮŲŰɄǗǛṸṺỦȔȖƯỤṲỨỪṶṴỮỬỰÚÙÛÜṼṾẂẀẆŴẄẈẊẌÝỲẎŶŸȲỸɎỶƳỴÝŹŻẐŽƵẒẔ"));1));MID(CONCATENATE("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBCCCCCCCCCDDDDDDDDDDEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEFFGGGGGGGGGHHHHHHHHHIIIIIIIIIIIIIIIIIIIJKKKKKKKLLLLLLLLLLLLMMMNNNNNNNNNNNNOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOPPPPRRRRRRRRRRRSSSSSSSSSSTTTTTTTTTTT";"UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUVVWWWWWWXXYYYYYYYYYYYYZZZZZZZ");FIND(MID(D2;ROW(X$1:INDEX(X:X;LEN(D2)));1);CONCATENATE("ÁÀȦÄǍĀÃÅĄȺẤẦẮẰǠǺǞẪẴẢȀȂẨẲẠḀẬẶĂÂḂɃƁḄḆĆĊĈČÇȻḈƇƆḊĎḐĐƊḌḒḎÐƉÉÈĖÊËĚĔĒẼĘȨɆẾỀḖḔỄḜẺȄȆỂẸḘḚỆÉÈÊËḞƑǴĠĜǦĞḠĢǤƓḢĤḦȞḨĦḤḪⱧÍÌÏǏĬĪĨĮƗḮỈȈȊỊḬÍÌÏÎĴḰǨĶƘḲḴⱩĹĿĽⱢⱠĻȽŁḶḼḺḸḾṀṂŃǸṄŇÑŅƝṆṊṈÑŊÓÒȮÔÖǑŎŌÕǪŐỐỒƟØṒṐṌȪỖṎǾȬǬỎȌȎƠỔỌỚỜỠỘỞỢÓÒÔÖÕṔṖⱣƤŔṘŘŖɌⱤȐȒṚṞṜŚṠŜŠṤṦṢṨŞȘṪŤƬṬȚƮṰṮȾŢŦ";"ÚÙÛÜǓŬŪŨŮŲŰɄǗǛṸṺỦȔȖƯỤṲỨỪṶṴỮỬỰÚÙÛÜṼṾẂẀẆŴẄẈẊẌÝỲẎŶŸȲỸɎỶƳỴÝŹŻẐŽƵẒẔ"));1));MID(D2;ROW(X$1:INDEX(X:X;LEN(D2)));1)))
Only Second formula return next:
T[h]is is simple ~s?tring $with Dia{cr}itic#s and Sy<mbols. /123
Both formulas (one after one) return next:
T i is is simple s tring with Dia cr itic s and sy mbols /123
I expect to see the same string, but with correct spacing:
This is simple string with Diacritics and Symbols /123
For this goal I combine both formulas in one single:
=SUBSTITUTE(CONCAT(IF(ISNUMBER(SEARCH("~"&MID(CONCAT(IFERROR(IF(EXACT(LOWER(MID(D2;ROW(X$1:INDEX(X:X;LEN(D2)));1));MID(D2;ROW(X$1:INDEX(X:X;LEN(D2)));1));LOWER(MID(CONCATENATE("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBCCCCCCCCCDDDDDDDDDDEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEFFGGGGGGGGGHHHHHHHHHIIIIIIIIIIIIIIIIIIIJKKKKKKKLLLLLLLLLLLLMMMNNNNNNNNNNNNOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOPPPPRRRRRRRRRRRSSSSSSSSSSTTTTTTTTTTT";"UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUVVWWWWWWXXYYYYYYYYYYYYZZZZZZZ");SEARCH("~"&MID(D2;ROW(X$1:INDEX(X:X;LEN(D2)));1);CONCATENATE("ÁÀȦÄǍĀÃÅĄȺẤẦẮẰǠǺǞẪẴẢȀȂẨẲẠḀẬẶĂÂḂɃƁḄḆĆĊĈČÇȻḈƇƆḊĎḐĐƊḌḒḎÐƉÉÈĖÊËĚĔĒẼĘȨɆẾỀḖḔỄḜẺȄȆỂẸḘḚỆÉÈÊËḞƑǴĠĜǦĞḠĢǤƓḢĤḦȞḨĦḤḪⱧÍÌÏǏĬĪĨĮƗḮỈȈȊỊḬÍÌÏÎĴḰǨĶƘḲḴⱩĹĿĽⱢⱠĻȽŁḶḼḺḸḾṀṂŃǸṄŇÑŅƝṆṊṈÑŊÓÒȮÔÖǑŎŌÕǪŐỐỒƟØṒṐṌȪỖṎǾȬǬỎȌȎƠỔỌỚỜỠỘỞỢÓÒÔÖÕṔṖⱣƤŔṘŘŖɌⱤȐȒṚṞṜŚṠŜŠṤṦṢṨŞȘṪŤƬṬȚƮṰṮȾŢŦ";"ÚÙÛÜǓŬŪŨŮŲŰɄǗǛṸṺỦȔȖƯỤṲỨỪṶṴỮỬỰÚÙÛÜṼṾẂẀẆŴẄẈẊẌÝỲẎŶŸȲỸɎỶƳỴÝŹŻẐŽƵẒẔ"));1));MID(CONCATENATE("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBCCCCCCCCCDDDDDDDDDDEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEFFGGGGGGGGGHHHHHHHHHIIIIIIIIIIIIIIIIIIIJKKKKKKKLLLLLLLLLLLLMMMNNNNNNNNNNNNOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOPPPPRRRRRRRRRRRSSSSSSSSSSTTTTTTTTTTT";"UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUVVWWWWWWXXYYYYYYYYYYYYZZZZZZZ");FIND(MID(D2;ROW(X$1:INDEX(X:X;LEN(D2)));1);CONCATENATE("ÁÀȦÄǍĀÃÅĄȺẤẦẮẰǠǺǞẪẴẢȀȂẨẲẠḀẬẶĂÂḂɃƁḄḆĆĊĈČÇȻḈƇƆḊĎḐĐƊḌḒḎÐƉÉÈĖÊËĚĔĒẼĘȨɆẾỀḖḔỄḜẺȄȆỂẸḘḚỆÉÈÊËḞƑǴĠĜǦĞḠĢǤƓḢĤḦȞḨĦḤḪⱧÍÌÏǏĬĪĨĮƗḮỈȈȊỊḬÍÌÏÎĴḰǨĶƘḲḴⱩĹĿĽⱢⱠĻȽŁḶḼḺḸḾṀṂŃǸṄŇÑŅƝṆṊṈÑŊÓÒȮÔÖǑŎŌÕǪŐỐỒƟØṒṐṌȪỖṎǾȬǬỎȌȎƠỔỌỚỜỠỘỞỢÓÒÔÖÕṔṖⱣƤŔṘŘŖɌⱤȐȒṚṞṜŚṠŜŠṤṦṢṨŞȘṪŤƬṬȚƮṰṮȾŢŦ";"ÚÙÛÜǓŬŪŨŮŲŰɄǗǛṸṺỦȔȖƯỤṲỨỪṶṴỮỬỰÚÙÛÜṼṾẂẀẆŴẄẈẊẌÝỲẎŶŸȲỸɎỶƳỴÝŹŻẐŽƵẒẔ"));1));MID(D2;ROW(X$1:INDEX(X:X;LEN(D2)));1)));ROW(X$1:INDEX(X:X;LEN(CONCAT(IFERROR(IF(EXACT(LOWER(MID(D2;ROW(X$1:INDEX(X:X;LEN(D2)));1));MID(D2;ROW(X$1:INDEX(X:X;LEN(D2)));1));LOWER(MID(CONCATENATE("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBCCCCCCCCCDDDDDDDDDDEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEFFGGGGGGGGGHHHHHHHHHIIIIIIIIIIIIIIIIIIIJKKKKKKKLLLLLLLLLLLLMMMNNNNNNNNNNNNOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOPPPPRRRRRRRRRRRSSSSSSSSSSTTTTTTTTTTT";"UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUVVWWWWWWXXYYYYYYYYYYYYZZZZZZZ");SEARCH("~"&MID(D2;ROW(X$1:INDEX(X:X;LEN(D2)));1);CONCATENATE("ÁÀȦÄǍĀÃÅĄȺẤẦẮẰǠǺǞẪẴẢȀȂẨẲẠḀẬẶĂÂḂɃƁḄḆĆĊĈČÇȻḈƇƆḊĎḐĐƊḌḒḎÐƉÉÈĖÊËĚĔĒẼĘȨɆẾỀḖḔỄḜẺȄȆỂẸḘḚỆÉÈÊËḞƑǴĠĜǦĞḠĢǤƓḢĤḦȞḨĦḤḪⱧÍÌÏǏĬĪĨĮƗḮỈȈȊỊḬÍÌÏÎĴḰǨĶƘḲḴⱩĹĿĽⱢⱠĻȽŁḶḼḺḸḾṀṂŃǸṄŇÑŅƝṆṊṈÑŊÓÒȮÔÖǑŎŌÕǪŐỐỒƟØṒṐṌȪỖṎǾȬǬỎȌȎƠỔỌỚỜỠỘỞỢÓÒÔÖÕṔṖⱣƤŔṘŘŖɌⱤȐȒṚṞṜŚṠŜŠṤṦṢṨŞȘṪŤƬṬȚƮṰṮȾŢŦ";"ÚÙÛÜǓŬŪŨŮŲŰɄǗǛṸṺỦȔȖƯỤṲỨỪṶṴỮỬỰÚÙÛÜṼṾẂẀẆŴẄẈẊẌÝỲẎŶŸȲỸɎỶƳỴÝŹŻẐŽƵẒẔ"));1));MID(CONCATENATE("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBCCCCCCCCCDDDDDDDDDDEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEFFGGGGGGGGGHHHHHHHHHIIIIIIIIIIIIIIIIIIIJKKKKKKKLLLLLLLLLLLLMMMNNNNNNNNNNNNOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOPPPPRRRRRRRRRRRSSSSSSSSSSTTTTTTTTTTT";"UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUVVWWWWWWXXYYYYYYYYYYYYZZZZZZZ");FIND(MID(D2;ROW(X$1:INDEX(X:X;LEN(D2)));1);CONCATENATE("ÁÀȦÄǍĀÃÅĄȺẤẦẮẰǠǺǞẪẴẢȀȂẨẲẠḀẬẶĂÂḂɃƁḄḆĆĊĈČÇȻḈƇƆḊĎḐĐƊḌḒḎÐƉÉÈĖÊËĚĔĒẼĘȨɆẾỀḖḔỄḜẺȄȆỂẸḘḚỆÉÈÊËḞƑǴĠĜǦĞḠĢǤƓḢĤḦȞḨĦḤḪⱧÍÌÏǏĬĪĨĮƗḮỈȈȊỊḬÍÌÏÎĴḰǨĶƘḲḴⱩĹĿĽⱢⱠĻȽŁḶḼḺḸḾṀṂŃǸṄŇÑŅƝṆṊṈÑŊÓÒȮÔÖǑŎŌÕǪŐỐỒƟØṒṐṌȪỖṎǾȬǬỎȌȎƠỔỌỚỜỠỘỞỢÓÒÔÖÕṔṖⱣƤŔṘŘŖɌⱤȐȒṚṞṜŚṠŜŠṤṦṢṨŞȘṪŤƬṬȚƮṰṮȾŢŦ";"ÚÙÛÜǓŬŪŨŮŲŰɄǗǛṸṺỦȔȖƯỤṲỨỪṶṴỮỬỰÚÙÛÜṼṾẂẀẆŴẄẈẊẌÝỲẎŶŸȲỸɎỶƳỴÝŹŻẐŽƵẒẔ"));1));MID(D2;ROW(X$1:INDEX(X:X;LEN(D2)));1))))));1);{" 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}));MID(CONCAT(IFERROR(IF(EXACT(LOWER(MID(D2;ROW(X$1:INDEX(X:X;LEN(D2)));1));MID(D2;ROW(X$1:INDEX(X:X;LEN(D2)));1));LOWER(MID(CONCATENATE("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBCCCCCCCCCDDDDDDDDDDEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEFFGGGGGGGGGHHHHHHHHHIIIIIIIIIIIIIIIIIIIJKKKKKKKLLLLLLLLLLLLMMMNNNNNNNNNNNNOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOPPPPRRRRRRRRRRRSSSSSSSSSSTTTTTTTTTTT";"UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUVVWWWWWWXXYYYYYYYYYYYYZZZZZZZ");SEARCH("~"&MID(D2;ROW(X$1:INDEX(X:X;LEN(D2)));1);CONCATENATE("ÁÀȦÄǍĀÃÅĄȺẤẦẮẰǠǺǞẪẴẢȀȂẨẲẠḀẬẶĂÂḂɃƁḄḆĆĊĈČÇȻḈƇƆḊĎḐĐƊḌḒḎÐƉÉÈĖÊËĚĔĒẼĘȨɆẾỀḖḔỄḜẺȄȆỂẸḘḚỆÉÈÊËḞƑǴĠĜǦĞḠĢǤƓḢĤḦȞḨĦḤḪⱧÍÌÏǏĬĪĨĮƗḮỈȈȊỊḬÍÌÏÎĴḰǨĶƘḲḴⱩĹĿĽⱢⱠĻȽŁḶḼḺḸḾṀṂŃǸṄŇÑŅƝṆṊṈÑŊÓÒȮÔÖǑŎŌÕǪŐỐỒƟØṒṐṌȪỖṎǾȬǬỎȌȎƠỔỌỚỜỠỘỞỢÓÒÔÖÕṔṖⱣƤŔṘŘŖɌⱤȐȒṚṞṜŚṠŜŠṤṦṢṨŞȘṪŤƬṬȚƮṰṮȾŢŦ";"ÚÙÛÜǓŬŪŨŮŲŰɄǗǛṸṺỦȔȖƯỤṲỨỪṶṴỮỬỰÚÙÛÜṼṾẂẀẆŴẄẈẊẌÝỲẎŶŸȲỸɎỶƳỴÝŹŻẐŽƵẒẔ"));1));MID(CONCATENATE("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBCCCCCCCCCDDDDDDDDDDEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEFFGGGGGGGGGHHHHHHHHHIIIIIIIIIIIIIIIIIIIJKKKKKKKLLLLLLLLLLLLMMMNNNNNNNNNNNNOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOPPPPRRRRRRRRRRRSSSSSSSSSSTTTTTTTTTTT";"UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUVVWWWWWWXXYYYYYYYYYYYYZZZZZZZ");FIND(MID(D2;ROW(X$1:INDEX(X:X;LEN(D2)));1);CONCATENATE("ÁÀȦÄǍĀÃÅĄȺẤẦẮẰǠǺǞẪẴẢȀȂẨẲẠḀẬẶĂÂḂɃƁḄḆĆĊĈČÇȻḈƇƆḊĎḐĐƊḌḒḎÐƉÉÈĖÊËĚĔĒẼĘȨɆẾỀḖḔỄḜẺȄȆỂẸḘḚỆÉÈÊËḞƑǴĠĜǦĞḠĢǤƓḢĤḦȞḨĦḤḪⱧÍÌÏǏĬĪĨĮƗḮỈȈȊỊḬÍÌÏÎĴḰǨĶƘḲḴⱩĹĿĽⱢⱠĻȽŁḶḼḺḸḾṀṂŃǸṄŇÑŅƝṆṊṈÑŊÓÒȮÔÖǑŎŌÕǪŐỐỒƟØṒṐṌȪỖṎǾȬǬỎȌȎƠỔỌỚỜỠỘỞỢÓÒÔÖÕṔṖⱣƤŔṘŘŖɌⱤȐȒṚṞṜŚṠŜŠṤṦṢṨŞȘṪŤƬṬȚƮṰṮȾŢŦ";"ÚÙÛÜǓŬŪŨŮŲŰɄǗǛṸṺỦȔȖƯỤṲỨỪṶṴỮỬỰÚÙÛÜṼṾẂẀẆŴẄẈẊẌÝỲẎŶŸȲỸɎỶƳỴÝŹŻẐŽƵẒẔ"));1));MID(D2;ROW(X$1:INDEX(X:X;LEN(D2)));1)));ROW(X$1:INDEX(X:X;LEN(CONCAT(IFERROR(IF(EXACT(LOWER(MID(D2;ROW(X$1:INDEX(X:X;LEN(D2)));1));MID(D2;ROW(X$1:INDEX(X:X;LEN(D2)));1));LOWER(MID(CONCATENATE("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBCCCCCCCCCDDDDDDDDDDEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEFFGGGGGGGGGHHHHHHHHHIIIIIIIIIIIIIIIIIIIJKKKKKKKLLLLLLLLLLLLMMMNNNNNNNNNNNNOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOPPPPRRRRRRRRRRRSSSSSSSSSSTTTTTTTTTTT";"UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUVVWWWWWWXXYYYYYYYYYYYYZZZZZZZ");SEARCH("~"&MID(D2;ROW(X$1:INDEX(X:X;LEN(D2)));1);CONCATENATE("ÁÀȦÄǍĀÃÅĄȺẤẦẮẰǠǺǞẪẴẢȀȂẨẲẠḀẬẶĂÂḂɃƁḄḆĆĊĈČÇȻḈƇƆḊĎḐĐƊḌḒḎÐƉÉÈĖÊËĚĔĒẼĘȨɆẾỀḖḔỄḜẺȄȆỂẸḘḚỆÉÈÊËḞƑǴĠĜǦĞḠĢǤƓḢĤḦȞḨĦḤḪⱧÍÌÏǏĬĪĨĮƗḮỈȈȊỊḬÍÌÏÎĴḰǨĶƘḲḴⱩĹĿĽⱢⱠĻȽŁḶḼḺḸḾṀṂŃǸṄŇÑŅƝṆṊṈÑŊÓÒȮÔÖǑŎŌÕǪŐỐỒƟØṒṐṌȪỖṎǾȬǬỎȌȎƠỔỌỚỜỠỘỞỢÓÒÔÖÕṔṖⱣƤŔṘŘŖɌⱤȐȒṚṞṜŚṠŜŠṤṦṢṨŞȘṪŤƬṬȚƮṰṮȾŢŦ";"ÚÙÛÜǓŬŪŨŮŲŰɄǗǛṸṺỦȔȖƯỤṲỨỪṶṴỮỬỰÚÙÛÜṼṾẂẀẆŴẄẈẊẌÝỲẎŶŸȲỸɎỶƳỴÝŹŻẐŽƵẒẔ"));1));MID(CONCATENATE("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBCCCCCCCCCDDDDDDDDDDEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEFFGGGGGGGGGHHHHHHHHHIIIIIIIIIIIIIIIIIIIJKKKKKKKLLLLLLLLLLLLMMMNNNNNNNNNNNNOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOPPPPRRRRRRRRRRRSSSSSSSSSSTTTTTTTTTTT";"UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUVVWWWWWWXXYYYYYYYYYYYYZZZZZZZ");FIND(MID(D2;ROW(X$1:INDEX(X:X;LEN(D2)));1);CONCATENATE("ÁÀȦÄǍĀÃÅĄȺẤẦẮẰǠǺǞẪẴẢȀȂẨẲẠḀẬẶĂÂḂɃƁḄḆĆĊĈČÇȻḈƇƆḊĎḐĐƊḌḒḎÐƉÉÈĖÊËĚĔĒẼĘȨɆẾỀḖḔỄḜẺȄȆỂẸḘḚỆÉÈÊËḞƑǴĠĜǦĞḠĢǤƓḢĤḦȞḨĦḤḪⱧÍÌÏǏĬĪĨĮƗḮỈȈȊỊḬÍÌÏÎĴḰǨĶƘḲḴⱩĹĿĽⱢⱠĻȽŁḶḼḺḸḾṀṂŃǸṄŇÑŅƝṆṊṈÑŊÓÒȮÔÖǑŎŌÕǪŐỐỒƟØṒṐṌȪỖṎǾȬǬỎȌȎƠỔỌỚỜỠỘỞỢÓÒÔÖÕṔṖⱣƤŔṘŘŖɌⱤȐȒṚṞṜŚṠŜŠṤṦṢṨŞȘṪŤƬṬȚƮṰṮȾŢŦ";"ÚÙÛÜǓŬŪŨŮŲŰɄǗǛṸṺỦȔȖƯỤṲỨỪṶṴỮỬỰÚÙÛÜṼṾẂẀẆŴẄẈẊẌÝỲẎŶŸȲỸɎỶƳỴÝŹŻẐŽƵẒẔ"));1));MID(D2;ROW(X$1:INDEX(X:X;LEN(D2)));1))))));1);"^^"));"^^";"")
And its working. But something is not right in my combination, because is an excessive long length.
I ask experts for a nicer, optimized combination of this two array formulas, using Excel-2019, without VBA or Helper Columns. Thank You.
To me the following worked:
Formula in A2:
=CONCAT(IFERROR(IF(EXACT(LOWER(MID(D2,ROW(X$1:INDEX(X:X,LEN(D2))),1)),MID(D2,ROW(X$1:INDEX(X:X,LEN(D2))),1)),LOWER(MID(CONCATENATE("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBCCCCCCCCCDDDDDDDDDDEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEFFGGGGGGGGGHHHHHHHHHIIIIIIIIIIIIIIIIIIIJKKKKKKKLLLLLLLLLLLLMMMNNNNNNNNNNNNOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOPPPPRRRRRRRRRRRSSSSSSSSSSTTTTTTTTTTT","UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUVVWWWWWWXXYYYYYYYYYYYYZZZZZZZ"),SEARCH("~"&MID(D2,ROW(X$1:INDEX(X:X,LEN(D2))),1),CONCATENATE("ÁÀȦÄǍĀÃÅĄȺẤẦẮẰǠǺǞẪẴẢȀȂẨẲẠḀẬẶĂÂḂɃƁḄḆĆĊĈČÇȻḈƇƆḊĎḐĐƊḌḒḎÐƉÉÈĖÊËĚĔĒẼĘȨɆẾỀḖḔỄḜẺȄȆỂẸḘḚỆÉÈÊËḞƑǴĠĜǦĞḠĢǤƓḢĤḦȞḨĦḤḪⱧÍÌÏǏĬĪĨĮƗḮỈȈȊỊḬÍÌÏÎĴḰǨĶƘḲḴⱩĹĿĽⱢⱠĻȽŁḶḼḺḸḾṀṂŃǸṄŇÑŅƝṆṊṈÑŊÓÒȮÔÖǑŎŌÕǪŐỐỒƟØṒṐṌȪỖṎǾȬǬỎȌȎƠỔỌỚỜỠỘỞỢÓÒÔÖÕṔṖⱣƤŔṘŘŖɌⱤȐȒṚṞṜŚṠŜŠṤṦṢṨŞȘṪŤƬṬȚƮṰṮȾŢŦ","ÚÙÛÜǓŬŪŨŮŲŰɄǗǛṸṺỦȔȖƯỤṲỨỪṶṴỮỬỰÚÙÛÜṼṾẂẀẆŴẄẈẊẌÝỲẎŶŸȲỸɎỶƳỴÝŹŻẐŽƵẒẔ")),1)),MID(CONCATENATE("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBCCCCCCCCCDDDDDDDDDDEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEFFGGGGGGGGGHHHHHHHHHIIIIIIIIIIIIIIIIIIIJKKKKKKKLLLLLLLLLLLLMMMNNNNNNNNNNNNOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOPPPPRRRRRRRRRRRSSSSSSSSSSTTTTTTTTTTT","UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUVVWWWWWWXXYYYYYYYYYYYYZZZZZZZ"),FIND(MID(D2,ROW(X$1:INDEX(X:X,LEN(D2))),1),CONCATENATE("ÁÀȦÄǍĀÃÅĄȺẤẦẮẰǠǺǞẪẴẢȀȂẨẲẠḀẬẶĂÂḂɃƁḄḆĆĊĈČÇȻḈƇƆḊĎḐĐƊḌḒḎÐƉÉÈĖÊËĚĔĒẼĘȨɆẾỀḖḔỄḜẺȄȆỂẸḘḚỆÉÈÊËḞƑǴĠĜǦĞḠĢǤƓḢĤḦȞḨĦḤḪⱧÍÌÏǏĬĪĨĮƗḮỈȈȊỊḬÍÌÏÎĴḰǨĶƘḲḴⱩĹĿĽⱢⱠĻȽŁḶḼḺḸḾṀṂŃǸṄŇÑŅƝṆṊṈÑŊÓÒȮÔÖǑŎŌÕǪŐỐỒƟØṒṐṌȪỖṎǾȬǬỎȌȎƠỔỌỚỜỠỘỞỢÓÒÔÖÕṔṖⱣƤŔṘŘŖɌⱤȐȒṚṞṜŚṠŜŠṤṦṢṨŞȘṪŤƬṬȚƮṰṮȾŢŦ","ÚÙÛÜǓŬŪŨŮŲŰɄǗǛṸṺỦȔȖƯỤṲỨỪṶṴỮỬỰÚÙÛÜṼṾẂẀẆŴẄẈẊẌÝỲẎŶŸȲỸɎỶƳỴÝŹŻẐŽƵẒẔ")),1)),IF(ISNUMBER(SEARCH("~"&MID(D2,ROW(X$1:INDEX(X:X,LEN(D2))),1),"/ 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")),MID(D2,ROW(X$1:INDEX(X:X,LEN(D2))),1),"")))
But granted, this is a painfull and seriously hard debugging for anyone if something come up that needs changing. Please don't ask me about it =)
Note: This worked with given sample data, but something simple like: Hello?You, will turn to HelloYou. Quite frankly, there is also simply no way to tell the difference in pure logic wheather or not you would want a space or not in this case if the input is this cluttered.
I wanna show the level range beside the alphabet, but does not work if I use Hlookup as normal, like the picture.
NOTE: This answer is based on my little understanding of the question.
I believe you can not (and should not) use Hlookup for this. The Ifs + Match functions should suffice. Paste the following code and drag down
=IFS(IFERROR(MATCH($B20,$B$8:$B$16,0),0)>0, $B$4, IFERROR(MATCH($B20,$C$8:$C$16,0),0)>0, $C$4, IFERROR(MATCH($B20,$D$8:$D$16,0),0)>0, $D$4, IFERROR(MATCH($B20,$E$8:$E$16,0), 0)>0, $E$4, IFERROR(MATCH($B20,$F$8:$F$16,0), 0)>0, $F$4)
See sample pic:
See sample workbook here at https://1drv.ms/x/s!AklQqQDqhBrtg2uBIiT6InszQqw6?e=1TZx37
I have a large spreadsheet with column data like:
ABC:1:I.0
ABC:1:I.1
ABC:1:I.2
ABC:1:I.3
ABC:2:I.0
ABC:2:I.1
ABC:2:I.2
ABC:2:I.3
ABC:3:I.0
ABC:3:I.2
ABC:3:I.3
ABC:4:I.0
ABC:4:I.1
ABC:4:I.2
ABC:4:I.3
ABC:5:I.0
ABC:5:I.1
ABC:5:I.2
ABC:5:I.3
ETC.
I need to replace the above with the following:
ABC:I.Data[1].0
ABC:I.Data[1].1
ABC:I.Data[1].2
ABC:I.Data[1].3
ABC:I.Data[2].0
ABC:I.Data[2].1
ABC:I.Data[2].2
ABC:I.Data[2].3
ABC:I.Data[3].0
ABC:I.Data[3].2
ABC:I.Data[3].3
ABC:I.Data[4].0
ABC:I.Data[4].1
ABC:I.Data[4].2
ABC:I.Data[4].3
ABC:I.Data[5].0
ABC:I.Data[5].1
ABC:I.Data[5].2
ABC:I.Data[5].3
ETC.
Here is a sample of the data, most of the data follows a similar format with the exception of the naming "ABC", which can vary in size, so it might be "ABCD" and also with the exception of the letter "I", it can be "O" as well. Also, some might be missing some values such as ABC:3:I.1 which is missing from the data. I am not too familiar with excel formulas or VBA code. Does anyone know how to do this? I have no preference on which method it has to be done in as I don't mind learning some VBA code if someone provides me with a VBA solution.
I was thinking of using some sort of loop along with some conditional statements.
Thanks!
Please try:
=LEFT(F11,FIND(":",F11))&MID(F11,FIND(":",F11,6)+1,1)&".Data["&MID(F11,FIND(":",F11,2)+1,1)&"]."&RIGHT(F11,1)
copied down to suit, assuming placed in Row11 and your data is in ColumnF starting in Row11.
Curiosities:
When this A was first posted it attempted to address only the tabulated example input and output. I temporarily deleted that version while addressing that what was in the table as ABC might at times be ABCD and that what was I might at times be O.
OP has posted an answer that I edited to make no visible change but which shows as the deletion of two characters. A copy of the OP’s formula exhibited a syntax error prior to my edit.
OP suggested an edit to my answer but this was rejected by the review process. As it happens, I think the edit suggestion was incorrect.
I have edited my answer again to include these ‘curiosities’ and to match the cell reference used by the OP in his answer.
=LEFT(A1,SEARCH(":",A1)) & MID(A1, SEARCH(".",A1)-1, 2) &
"Data[" & MID(A1,SEARCH(":",A1)+1,1) & "]" & RIGHT(A1,2)
With the help of pnuts I was able to come up with my own solution:
=LEFT(F11,LEN(F11)-5)&MID(F11,LEN(F11)-2,2)&"Data["&MID(F11,LEN(F11)-4,1)&"]"&RIGHT(F11,2)
My solution works based on the fact that the length of the last six values in the string ABC:1:I:0 will always be the same in size for all the data I have, hence you see LEN(F11)-some number in my code. The only part of the string that changes in size is the first part, in this case ABC which can also be ABCDEF, etc.
If you'd like to use formulas rather than VBA, an easy option is to split the data into 4 columns, using the Text To Columns option - first split using the colon as a delimiter, then using a full-stop / period as a delimiter.
Once you have 4 columns of data (one for each block), you can use the Concatenate function to join them and add in the extra characters: =CONCATENATE(A1,":",C1,".","Data[",B1,"].",D1)
This should still work if you have extra / alternative characters (eg ABCD instead of ABC), as long as you have the same delimiters, but obviously you'd need to test to make sure.
Seems like it would be a simple thing really (and it may be), but I'm trying to take the string data of a column and then through a calculated column, replace all the spaces with %20's so that the HTML link in the workflow produced email will actually not break off at the first space.
For example, we have this in our source column:
file:///Z:/data/This is our report.rpt
And would like to end up with this in the calculated column:
file:///Z:/data/This%20is%20our%20report.rpt
Already used the REPLACE, and made up a ghastly super nested REPLACE/SEARCH version, but the problem there is that you have to nest for EACH potential space, and if you don't know how many up front, it doesn't work, or will miss some.
Have any of you come across this scenario and how did you handle it?
Thanks in advance!
As far as I know there is no generic solution using the calculated-column syntax. The standard solution for this situation is using an ItemAdded (/ItemUpdated) event and initializing the field value from code.
I was able to solve this issue for my circumstances by using a series of calculated columns.
In the first calculated column (C1) I entered a formula to remove the first space, something like this:
=IF(ISNUMBER(FIND(" ",[Title])),REPLACE([Title],FIND(" ",[Title]),1,"%20"),[Title])
In the second Calculated column (C2) I used:
=IF(ISNUMBER(FIND(" ",[C1])),REPLACE([C1],FIND(" ",[C1]),1,"%20"),[C1]).
In my case, I wanted to encode upto four spaces, so I used 3 calculated columns (C1, C2, C3) in the same fashion and got the desired result.
This is not as efficient as using a single calculated column, but if SUBSTITUTE will not work in your SharePoint environment, and you cannot use an event handler or workflow, it may offer a workable alternative.
I actually used a slightly different formula, but it was on a work machine to which I don't have access at the moment, so I just grabbed this formula from a similar S.O. question. Any formula that will replace the first occurrence of a space with "%20" will work, the trick is to a) make sure the formula returns the original string unchanged if it does not have more spaces in it, and b) test, test, test. Create a view of your list that has the field you are trying to encode, plus the calculated fields, and see if you are getting the results you want.
so that the HTML link in the workflow produced email will actually not break off at the first space.
The browser only does this if you have not enclosed your link in quotes
If you wrap the link in quotes, it does not cut off at the first space
In a SharePoint Formula it would be:
="""file:///Z:/data/This is our report.rpt"""
becuase two quotes are the SP escape notation to output a quote
You can use this formula (Start trim for 1, in my case was 4):
=IF(ISBLANK([EUR Amount]),"",(TRIM(MID([EUR Amount],4,2))&TRIM(MID([EUR Amount],6,2))&TRIM(MID([EUR Amount],8,2))&TRIM(MID([EUR Amount],10,2))&TRIM(MID([EUR Amount],12,2))&TRIM(MID([EUR Amount],14,2)))*1)