ATEXTSPLIT

=ATEXTSPLIT(ar,dl,ea)

ar
array strings, 1D vertical
dl
string, one or more characters
ea
0 or 1, 0 or omitted ignores empty ; 1 does not ignore empty

array text split by any delimiter,(one or more chars), fine-tuned for complex scenarios

Xlambda

Well-known Member
Joined
Mar 8, 2021
Messages
832
Office Version
  1. 365
Platform
  1. Windows
ATEXTSPLIT array text split by any delimiter,(one or more chars), fine-tuned for complex scenarios.
Wrote this function inspired by MrExcel video: Excel TEXTJOIN And The Need For TEXTSPLIT with Ann K. Emery - 2407
The idea was to create a function that is clean and robust, does not call other functions, non-recursive, no FILTERXML, and uses same arguments as TEXTJOIN. What TEXTJOIN joins, ATEXTSPLIT should be able to split it back like it was, with same arguments. When we join, we choose the delimiter, but when we split imported data, things can go quite tricky.
ar: array 1D vertical, dl: delimiter, any string , ea: empty argument , 0 or omitted - ignores empty ; 1 - does not ignore empty
Note: There are 2 special characters in the formula, (h,"º",d,"ª"), first variables after "LET" . These should be changed if any of them is found on the array of strings. Formula advises if this happens.
Excel Formula:
=LAMBDA(ar,dl,ea,
    LET(h,"º",d,"ª",ch,ISNUMBER(SEARCH(CHOOSE({1,2},h,d),ar)),
       a,SUBSTITUTE(ar,dl,d),b,IF(ea,a,SUBSTITUTE(SUBSTITUTE(TRIM(SUBSTITUTE(SUBSTITUTE(a," ",h),d," "))," ",d),h," ")),
       n,LEN(b)-LEN(SUBSTITUTE(b,d,""))+1,c,MAX(n),sc,SEQUENCE(,c),
       x,SEARCH(h,SUBSTITUTE(d&b,d,h,sc)),y,SEARCH(h,SUBSTITUTE(b&d,d,h,sc)),m,IFERROR(MID(b,x,y-x),""),
       IF(OR(ch),"change special chars",IFERROR(--m,m))
    )
)
LAMBDA 7.0.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAI
1TEXTJOINATEXTSPLIT
2empty ignoredempty not ignored2 charsempty ignored
3empty not ignoredea arg.=0ea arg.=1delimiterea arg.=0
4sample=TEXTJOIN(",",0,A5:D5)=ATEXTSPLIT(F5:F7,",",)=ATEXTSPLIT(F5:F7,",",1)=ATEXTSPLIT(T5:T7,"><",)LEN check
5a4ca,4,,ca4ca4ca><6.8><ta6.8t131
6d0.5d,,,0.5d0.5d0.5><2.4 w><2.4 w600
7g hi 2k l3 ng h,i 2,k l,3 ng hi 2k l3 ng hi 2k l3 n<Ac4><gh>< ><<Ac4gh 421
8space
9empty ignoredea arg.=0ea arg.=1empty not ignored
10=TEXTJOIN(",",,A5:D5)=ATEXTSPLIT(F11:F13,",",)=ATEXTSPLIT(F11:F13,",",1)ea arg.=1
11a,4,ca4ca4c=ATEXTSPLIT(T5:T7,"><",1)LEN check
12d,0.5d0.5d0.5a6.8t1310
13g h,i 2,k l,3 ng hi 2k l3 ng hi 2k l3 n2.4 w0600
14<Ac4gh 4210
15Complex scenariospace followed by an empty string
16empty ignoredempty not ignored
17ea arg.=0ea arg.=1error debug.
18sample=ATEXTSPLIT(F19:F22,",",)=ATEXTSPLIT(F19:F22,",",1)=ATEXTSPLIT(X19,",",)
19a,b,c,2.3,,d e,abc2.3d eabc2.3d ea,ºb,cchange special chars
20,,g,,h, ,1.8gh 1.8gh 1.8=ATEXTSPLIT(X21,",",1)
21, k m, ,4.9, ,p k m 4.9 p k m 4.9 pa,ªb,cchange special chars
22, ,,x 4, ,, x 4 x 4
23
24Important Obs.: -two delimiters next to each other ( ,, ) , hold an empty string between them that can be ignored or not depending of "ea" argument
25 -two delimiters sep by space ( , , ) , hold a space between them, and can not be ignored, no matter of "ea" argument
26 We can check this behaviour with LEN function. (same rule applies for leading or trailing delimiters)
27
28=LEN(H19#)=LEN(N19#)
29111331113030
30111300010113
31413110413110
32151000105100
33
34- if values themselves embed inner spaces, could be important to keep them (like special codes with fixed length that follow a pattern),TRIM tweaks can not be used
35
36ex. code patternsample=ATEXTSPLIT(F37:F38,"/",)=LEN(H37#)
37fixed with 4 pos.a bc/a b/ bcda bca b bcd444
38/____ /ab d/ d/a ab d da 444
39/xxxx/check:pattern is kept
40
ATEXTSPLIT post
Cell Formulas
RangeFormula
H4,N36,H36,N28,H28,Z18,Z20,N18,H18,F10,X11,N10,H10,F4,X4,N4H4=FORMULATEXT(H5)
H5:K7,H11:K13H5=ATEXTSPLIT(F5:F7,",",)
N5:Q7,N11:Q13N5=ATEXTSPLIT(F5:F7,",",1)
X5:Z7X5=ATEXTSPLIT(T5:T7,"><",)
AC5:AE7,AC12:AF14AC5=LEN(X5#)
F5:F7F5=TEXTJOIN(",",0,A5:D5)
X12:AA14X12=ATEXTSPLIT(T5:T7,"><",1)
F11:F13F11=TEXTJOIN(",",,A5:D5)
H19:L22H19=ATEXTSPLIT(F19:F22,",",)
N19:T22N19=ATEXTSPLIT(F19:F22,",",1)
Z19Z19=ATEXTSPLIT(X19,",",)
Z21Z21=ATEXTSPLIT(X21,",",1)
H29:L32,N29:T32H29=LEN(H19#)
H37:J38H37=ATEXTSPLIT(F37:F38,"/",)
N37:P38N37=LEN(H37#)
Dynamic array formulas.
 
Upvote 0
What if we have 2 or more decks, each shuffled, NDECK(n ) (no dups/row) that we want to shuffle them, riffle style. (see attached pic)
Shuffling riffle style. Concept.
ATEXTSPILL.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAXAYAZBABB
1Shuffling n decks. Riffle style. Concept
2
3=NDECK(2)
42♣9♣10♦4♦4♠A♣J♣6♠3♦2♠6♣5♠J♥8♥Q♣10♠8♦8♠7♦A♦5♣10♥A♥A♠9♥K♣4♣2♦3♣K♠9♦Q♥3♠K♦9♠2♥6♦Q♠10♣8♣7♣7♥Q♦4♥J♦3♥6♥7♠J♠5♦K♥5♥
56♦Q♦A♦9♥2♠10♥8♠7♦J♣2♥4♠K♦7♠3♠3♣7♥2♣5♦3♦A♥10♣3♥5♣8♦10♦9♠10♠A♣9♦4♣J♦K♠K♣6♥Q♥4♥A♠7♣J♠K♥6♠Q♣6♣5♠Q♠4♦8♣8♥5♥J♥9♣2♦
6
7shuffling 2 decks, riffle style, possible if we use scan_by_colum argument = 1 in TOCOL
8=WRAPROWS(TOCOL(B4#,,1),52)
92♣6♦9♣Q♦10♦A♦4♦9♥4♠2♠A♣10♥J♣8♠6♠7♦3♦J♣2♠2♥6♣4♠5♠K♦J♥7♠8♥3♠Q♣3♣10♠7♥8♦2♣8♠5♦7♦3♦A♦A♥5♣10♣10♥3♥A♥5♣A♠8♦9♥10♦K♣9♠
104♣10♠2♦A♣3♣9♦K♠4♣9♦J♦Q♥K♠3♠K♣K♦6♥9♠Q♥2♥4♥6♦A♠Q♠7♣10♣J♠8♣K♥7♣6♠7♥Q♣Q♦6♣4♥5♠J♦Q♠3♥4♦6♥8♣7♠8♥J♠5♥5♦J♥K♥9♣5♥2♦
11
12
13NDECK(2) has no dups /row
14shufflled decks should/can have dups/row
15B16:B17=COUNTIF(B9:BA9,DECK())
162121112111000210210011121111000112221000211122022011
170101110111222012012211101111222110001222011100200211
18
19also total nr. of occurences should be = total nr. of decks (2), no more, no less
20=COUNTIF(B9#,DECK())
212222222222222222222222222222222222222222222222222222
22
23Shuffling 3 decks
24
25=NDECK(3)
26A♦Q♣5♥8♥8♠K♠2♥9♥K♥5♦7♠A♣J♦J♣6♣2♠4♣A♠10♣6♥7♦6♦4♦4♥7♣9♠9♦Q♦9♣2♦3♣3♠6♠J♥10♠Q♠K♦5♣K♣7♥5♠3♥3♦A♥J♠8♣8♦Q♥4♠2♣10♥10♦
276♦6♥6♣4♥Q♣7♥3♣J♥3♠2♠K♦Q♦3♥5♠4♠2♥3♦A♠8♦10♠Q♥A♦10♥8♠Q♠A♣J♠8♣4♦8♥7♠4♣K♠J♦5♣K♥5♥10♦5♦9♣A♥2♣10♣6♠7♣J♣K♣9♥7♦9♦9♠2♦
284♠8♣7♠9♦10♠K♣A♦6♥6♠10♦10♣8♠2♦7♦K♠6♦3♣5♣A♠Q♥5♦3♠4♣A♣8♥6♣7♥9♥2♠Q♦Q♠10♥J♣3♦2♣2♥A♥5♠4♥9♠J♥7♣J♠5♥J♦9♣3♥K♥8♦K♦Q♣4♦
29
30=WRAPROWS(TOCOL(B26#,,1),52)
31A♦6♦4♠Q♣6♥8♣5♥6♣7♠8♥4♥9♦8♠Q♣10♠K♠7♥K♣2♥3♣A♦9♥J♥6♥K♥3♠6♠5♦2♠10♦7♠K♦10♣A♣Q♦8♠J♦3♥2♦J♣5♠7♦6♣4♠K♠2♠2♥6♦4♣3♦3♣A♠
32A♠5♣10♣8♦A♠6♥10♠Q♥7♦Q♥5♦6♦A♦3♠4♦10♥4♣4♥8♠A♣7♣Q♠8♥9♠A♣6♣9♦J♠7♥Q♦8♣9♥9♣4♦2♠2♦8♥Q♦3♣7♠Q♠3♠4♣10♥6♠K♠J♣J♥J♦3♦10♠5♣
332♣Q♠K♥2♥K♦5♥A♥5♣10♦5♠K♣5♦4♥7♥9♣9♠5♠A♥J♥3♥2♣7♣3♦10♣J♠A♥6♠5♥J♠7♣J♦8♣J♣9♣8♦K♣3♥Q♥9♥K♥4♠7♦8♦2♣9♦K♦10♥9♠Q♣10♦2♦4♦
34
35cheching total occurences = 3
36=COUNTIFS(B31#,DECK())
373333333333333333333333333333333333333333333333333333
38
DECK 3
Cell Formulas
RangeFormula
B3,B36,B30,B25,B20,B8B3=FORMULATEXT(B4)
B4:BA5B4=NDECK(2)
B9:BA10,B31:BA33B9=WRAPROWS(TOCOL(B4#,,1),52)
E15E15=FORMULATEXT(B16)
B16:BA17B16=COUNTIF(B9:BA9,DECK())
B21:BA21B21=COUNTIF(B9#,DECK())
B26:BA28B26=NDECK(3)
B37:BA37B37=COUNTIFS(B31#,DECK())
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
1:1048576Expression=OR(UNICODE(RIGHT(A1,1))=9829,UNICODE(RIGHT(A1,1))=9830)textNO
 

Attachments

  • shuffling 2 decks.jpg
    shuffling 2 decks.jpg
    56.2 KB · Views: 7
SNDECK([nd],[ch],[nh]) Shuffling nd decks of cards and dealing them, nr. of cards/hand ch, nh number of hands (gets calculated)
[nd]: number of decks
if omitted => 1 deck
[ch]: cards/hand
if omitted => all cards in a single hand => 1 row, nd*52 cards (columns)
[nh]: nr. of hands gets calculated according to total nr of cards and cards/hand ch
if nh omitted => all hands to finish all cards, last hand can have <= ch, total nr of hands = roundup(nd*52/ch,0)
if nh< total nr hands, only the first nh will be returned
if nh=-1, last hand if it has <ch nr of cards, will not be returned => returns only hands that have ch cards
if nh> tot nh => nh=total nh
The function will return as top left cell info about nr. of rows(nh) x nr. of columns (ch)
Excel Formula:
=LAMBDA([nd], [ch], [nh],
    LET(
        m, MAX(nd, 1) * 52,
        d, NDECK(nd),
        f, SORTBY(TOCOL(d, , 1), RANDARRAY(m)),
        c, IF(ch, MIN(ch, m), m),
        a, IF(c = m, TOROW(f), WRAPROWS(f, c, "")),
        r, ROWS(a),
        b, IF(OR(a = ""), TAKE(a, r - 1), a),
        x, IFS(nh < 0, b, nh = 0, a, nh < r, TAKE(b, nh), 1, a),
        IFNA(VSTACK(ROWS(x) & "x" & COLUMNS(x), x), "")
    )
)
ATEXTSPILL.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAXAYAZBA
1
2=SNDECK()
31x52
4K♠J♣Q♦2♦A♠2♣9♦4♥J♠4♦Q♠6♠3♥10♣A♦K♦9♠6♦A♣4♣7♠10♠8♣2♥10♦4♠9♥6♥J♦7♣3♦8♠Q♣6♣10♥5♦K♣3♣Q♥8♦5♣7♥7♦9♣J♥K♥3♠8♥A♥5♠2♠5♥
5
6nd,1 (single deck), ch,5nh,-1 => last row not returnednd,2,ch,7nd,2,ch,7,nh,-1nd,2,ch,7,nh,10
7=SNDECK(1,5)=SNDECK(1,5,-1)=SNDECK(2,7)=SNDECK(2,7,-1)=SNDECK(3,7,10)
811x510x515x714x710x7
95♣7♣A♣10♦Q♣8♦5♥6♠Q♦K♣8♦9♦3♠7♦A♠10♦A♦7♣8♣10♣10♦6♠4♠6♥4♣9♦A♥7♦10♥A♣9♣
104♠6♠9♣2♣K♥8♥5♠5♣2♦4♥2♠J♣3♥5♦J♦2♠3♦A♦Q♦Q♣5♥9♠4♣9♣5♠Q♦K♦K♥J♣6♥9♥
11A♠Q♠5♠7♥5♦9♦9♥4♠J♦6♦4♠5♠4♦7♠5♦A♣10♥5♠K♦J♦9♦J♣Q♥9♣10♦K♠5♣Q♥8♥8♣Q♠
122♥2♠3♣5♥6♣J♥9♠Q♥2♠J♣10♠7♥9♥9♦Q♠8♠J♥5♦A♣4♥3♥5♠A♦K♠2♥J♣8♠K♣J♠8♠A♣
1310♠8♥K♦2♦9♦7♣A♥A♠7♦A♣4♥8♦6♦A♣K♣K♠4♦4♣2♥J♣10♥J♥9♥9♥4♦J♠6♦K♦2♠A♦8♦
144♦J♦3♠J♣10♥K♥A♦9♣2♥K♦Q♦10♠5♥8♣6♦J♦2♦7♦2♣10♣2♦10♠3♦8♦Q♥7♠2♦K♥3♣A♦5♣
15J♥A♥10♣3♥Q♦K♠3♠10♣3♥8♣7♥Q♣K♣6♣J♥6♣Q♦4♦8♥6♥Q♦6♠4♦8♣K♥7♣4♠5♠9♠2♣A♣
163♦K♣9♥8♠8♣Q♠10♥10♠6♥8♠6♥6♥K♦8♥2♥4♣9♠10♠7♠3♥2♠9♠K♥K♥8♣10♣J♥4♥3♥8♦5♥
176♥9♠4♣4♥Q♥Q♣4♦4♣5♦2♣9♣Q♥4♣8♣J♣A♥K♦3♣A♥7♣2♦8♠4♥9♦6♠5♥3♦5♠4♥10♥J♥
188♦7♦6♦J♠7♠J♠7♠3♦10♦6♣3♣7♦10♣9♣7♣3♥9♠8♦J♥5♣7♠K♣7♦2♠Q♥6♣9♥10♠3♦8♥10♠
19K♠A♦5♥9♥J♠4♠3♣2♣8♠A♠3♦Q♥8♠A♣3♣K♠
207♣A♠2♣5♣10♥3♦K♥6♦J♠8♥7♥2♣K♦3♠
2110♦Q♠4♥6♠A♥2♥J♠10♦A♠4♠2♥Q♣10♥J♠
2210♣2♦8♥A♦K♥5♠7♠Q♠3♠6♣7♥J♦Q♠5♥
23Q♣Q♥K♠3♠5♣6♠
24
25nd,3,ch,13,nh,omitted (all hands complete,tot cards divide by ch=13)since all 3 decks are shuffled separate and toghether also,
26=SNDECK(3,13)rows can have dups, extracting unique by row
2712x13=ATEXTSPILL(SEQUENCE(52*3/13),LAMBDA(x,UNIQUE(INDEX(B28:N39,x,),1)))
285♦7♣2♦9♥K♥9♥7♣2♦A♣8♦7♠A♥4♣5♦7♣2♦9♥K♥A♣8♦7♠A♥4♣
297♦10♠2♥3♣2♦K♣9♥6♦Q♥5♠3♥8♣4♦7♦10♠2♥3♣2♦K♣9♥6♦Q♥5♠3♥8♣4♦
30K♥Q♠A♥8♥Q♦J♦K♦10♣K♠8♠A♣3♣9♣K♥Q♠A♥8♥Q♦J♦K♦10♣K♠8♠A♣3♣9♣
3110♥J♣J♠8♦3♠5♥10♦2♣4♦3♠8♠6♦9♦10♥J♣J♠8♦3♠5♥10♦2♣4♦8♠6♦9♦
324♠5♦Q♣5♣Q♥Q♦4♣8♠3♣6♠3♦J♥10♦4♠5♦Q♣5♣Q♥Q♦4♣8♠3♣6♠3♦J♥10♦
336♥8♥6♥4♥Q♣9♣4♣5♦2♣7♥K♠Q♦6♠6♥8♥4♥Q♣9♣4♣5♦2♣7♥K♠Q♦6♠
3410♥9♦3♥K♣K♥J♣J♥A♠2♣6♦5♠2♥7♥10♥9♦3♥K♣K♥J♣J♥A♠2♣6♦5♠2♥7♥
353♦7♠8♣4♠J♠3♦7♠5♠7♦6♣8♥J♦9♠3♦7♠8♣4♠J♠5♠7♦6♣8♥J♦9♠
365♥10♣4♥5♥A♠4♦2♥7♦Q♠K♦J♣10♣A♦5♥10♣4♥A♠4♦2♥7♦Q♠K♦J♣A♦
37Q♣4♠6♠2♠3♠5♣10♠9♣10♥A♦7♣7♥A♣Q♣4♠6♠2♠3♠5♣10♠9♣10♥A♦7♣7♥A♣
38A♥J♠9♦9♠6♥K♣3♥Q♠A♠4♥5♣K♦8♣A♥J♠9♦9♠6♥K♣3♥Q♠A♠4♥5♣K♦8♣
399♠8♦6♣J♥J♦Q♥K♠2♠A♦2♠6♣10♠10♦9♠8♦6♣J♥J♦Q♥K♠2♠A♦10♠10♦
40
DECK 4
Cell Formulas
RangeFormula
B2,P27,B26,AE7,W7,O7,H7,B7B2=FORMULATEXT(B3)
B3:BA4B3=SNDECK()
B8:F19B8=SNDECK(1,5)
H8:L18H8=SNDECK(1,5,-1)
O8:U23O8=SNDECK(2,7)
W8:AC22W8=SNDECK(2,7,-1)
AE8:AK18AE8=SNDECK(3,7,10)
B27:N39B27=SNDECK(3,13)
P28:AB39P28=ATEXTSPILL(SEQUENCE(52*3/13),LAMBDA(x,UNIQUE(INDEX(B28:N39,x,),1)))
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
1:1048576Expression=OR(UNICODE(RIGHT(A1,1))=9829,UNICODE(RIGHT(A1,1))=9830)textNO
 
ATEXTSPILL.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAXAYAZBABB
1RECAP
2
3DECK() single deck in order
4=DECK()
52♠3♠4♠5♠6♠7♠8♠9♠10♠A♠J♠Q♠K♠2♣3♣4♣5♣6♣7♣8♣9♣10♣A♣J♣Q♣K♣2♥3♥4♥5♥6♥7♥8♥9♥10♥A♥J♥Q♥K♥2♦3♦4♦5♦6♦7♦8♦9♦10♦A♦J♦Q♦K♦
6
7NDECK(n) shuffles n decks of cards individually (no dups/row)
8=NDECK(4)
96♥Q♥3♦7♠5♣9♥A♠Q♦3♣7♣J♦8♥Q♠K♥2♥5♠6♣6♦J♥10♦A♦4♥K♦Q♣10♣9♦9♣8♣J♣A♣K♠4♣4♦5♦3♥8♠J♠2♦9♠2♣5♥8♦7♥K♣10♥3♠4♠A♥10♠7♦2♠6♠
1010♣7♣5♣10♠10♥4♣2♥K♦2♦J♠4♠2♠3♣K♥5♥4♦5♦8♦A♠6♥6♦7♠6♣Q♠Q♣3♠9♣K♠Q♥3♥2♣6♠A♦9♥8♠8♥J♥A♣10♦9♦Q♦4♥3♦9♠5♠J♦J♣K♣7♥7♦A♥8♣
11A♠5♦7♦8♦4♥3♣Q♣K♦10♣9♠5♥J♠Q♠5♣10♠10♦2♣6♦3♦4♦9♦6♠5♠8♥K♥3♠J♥J♦2♦Q♦6♣A♥K♣9♣6♥8♠4♠3♥2♠2♥4♣8♣7♠7♥J♣K♠9♥A♣A♦Q♥7♣10♥
12K♦A♦2♦2♠A♠10♠3♠6♥Q♦5♦4♣9♥3♥6♠4♥5♠6♣8♠K♣A♥Q♠3♣8♣3♦4♠7♦Q♣4♦9♣A♣10♥9♦8♦7♠K♥J♦Q♥5♣5♥J♣8♥7♥K♠10♣2♥J♠10♦2♣9♠J♥6♦7♣
13
14count occurrences/rowcount all occurrences
1552=SUM(COUNTIF(B9:BA9,DECK()))=SUM(COUNTIF(B9#,DECK()))
1652=SUM(COUNTIF(B10:BA10,DECK()))208
1752=SUM(COUNTIF(B11:BA11,DECK()))=4*52
1852=SUM(COUNTIF(B12:BA12,DECK()))208
19
20SNDECK([nd],[ch],[nh]), shuffles and deals nh hands of ch cards/hand
21the function does 3 shuffles, 1st done by NDECK function, each deck individually, 2nd riffle shuffle with TOCOL, 3rd shuffle another sortby with randarray
22
23LAMBDA([nd], [ch], [nh], LET( m, MAX(nd, 1) * 52, d, NDECK(nd), f, SORTBY(TOCOL(d, , 1), RANDARRAY(m)),
24
25
26←←1st shuffle
27
28↑↑↑↑
292nd shuffle3rd shuffle
30riffle shuffle
31can have dups/row
32=SNDECK(4,13)count all occurrencescount unique/row
3316x13=SUM(COUNTIF(B34:N49,DECK()))=BYROW(B34:N49,LAMBDA(x,COLUMNS(UNIQUE(x,1))))
34A♦9♣10♠4♥K♠8♠8♣4♣7♠Q♦7♣8♥4♣20812TRUE
356♣A♦2♣2♥8♥7♦6♥5♣7♠K♣6♦4♠A♥13FALSE
369♠8♦9♣8♣Q♠4♥6♦J♦3♥4♥5♥A♠9♠11TRUE
37K♦2♦8♥A♥K♠7♦9♠6♠10♣K♥4♣6♥3♥13FALSE
385♠8♦J♥A♠3♣Q♣3♥8♣J♣5♠10♦5♥Q♣11TRUE
39J♠10♦Q♠2♠J♠9♥5♦10♦8♥Q♥3♦J♥Q♥10TRUE
402♦6♣J♦K♦5♣4♦6♦Q♥A♠2♥6♠9♦10♣13FALSE
417♦J♥A♠5♣9♣3♦5♣8♠10♠J♠A♣4♠2♣12TRUE
4210♥A♦3♠4♠Q♥7♠K♠6♦J♣2♦6♣9♠A♦12TRUE
438♦J♠K♦Q♣3♣2♥8♠7♠8♣A♥7♣5♦A♣13FALSE
44Q♣7♥4♥5♠3♠J♦7♥9♥2♠2♦K♥2♠2♠10TRUE
45Q♦3♣Q♠K♣7♣3♦4♠K♣3♣9♦8♦6♥5♥11TRUE
46K♣5♠3♠K♦9♥3♠10♥10♥4♦6♠7♦10♣2♥11TRUE
47A♥K♥2♣5♥J♣9♦10♣K♠6♣3♦9♦3♥10♥12TRUE
484♦5♦Q♦Q♦5♦4♦7♥9♣Q♠J♣7♥10♦A♣9TRUE
494♣6♥6♠K♥J♥J♦2♣10♠9♥10♠8♠7♣A♣12TRUE
50=V34#<13
51rows with dups
52
DECK 5
Cell Formulas
RangeFormula
B4,P33,V33,B32,J17,J15,B8B4=FORMULATEXT(B5)
B5:BA5B5=DECK()
B9:BA12B9=NDECK(4)
B15:B18B15=SUM(COUNTIF(B9:BA9,DECK()))
C15:C18C15=FORMULATEXT(B15)
J16J16=SUM(COUNTIF(B9#,DECK()))
J18J18=4*52
B33:N49B33=SNDECK(4,13)
P34P34=SUM(COUNTIF(B34:N49,DECK()))
V34:V49V34=BYROW(B34:N49,LAMBDA(x,COLUMNS(UNIQUE(x,1))))
X34:X49X34=V34#<13
X50X50=FORMULATEXT(X34)
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
1:1048576Expression=OR(UNICODE(RIGHT(A1,1))=9829,UNICODE(RIGHT(A1,1))=9830)textNO
X34:X49Expression=X34textNO
 
HowToSplitASentenceWithNoDelimiters?
This is inspired by an off-topic comment posted by B C on latest Chandoo's YT: Data Cleaning PRO Tip: Dealing with text & numbers in same column
B C's post:
"Thanks, Chandoo! Question: HowWouldYouAddSpacesAtCapitalLetters?"
text-and-values.xlsx
ABCDEFGHIJKLM
1
2sample
3HowToSplitASentenceWithNoDelimiters?
4HowWouldYouAddSpacesAtCapitalLetters?
5Axxx,Bxx,CDE,FxG
6
7capital letters formula
8=CHAR(SEQUENCE(26,,65))
9A
10B1st solution, when all capital letters belong to standard alphabet
11C
12D=REDUCE(C3:C5,CHAR(SEQUENCE(26,,65)),LAMBDA(v,x,TRIM(SUBSTITUTE(v,x," "&x))))
13EHow To Split A Sentence With No Delimiters?
14FHow Would You Add Spaces At Capital Letters?
15GAxxx, Bxx, C D E, Fx GTo extract the words
16H=ATEXTSPILL(C13#,LAMBDA(x,TEXTSPLIT(x,{" ",",","?"},,1)))
17IHowToSplitASentenceWithNoDelimiters
18JHowWouldYouAddSpacesAtCapitalLetters
19KAxxxBxxCDEFxG
20L
21Mor this extraction
22N=IF(SEQUENCE(,COLUMNS(E17#))=1,E17#,LOWER(E17#))
23OHowtosplitasentencewithnodelimiters
24PHowwouldyouaddspacesatcapitalletters
25QAxxxbxxcdefxg
26R
27S
28T
29U
30V
31W
32X
33Y
34Z
35
cap lett. 1
Cell Formulas
RangeFormula
A8,E22,E16,C12A8=FORMULATEXT(A9)
A9:A34A9=CHAR(SEQUENCE(26,,65))
C13:C15C13=REDUCE(C3:C5,CHAR(SEQUENCE(26,,65)),LAMBDA(v,x,TRIM(SUBSTITUTE(v,x," "&x))))
E17:L19E17=ATEXTSPILL(C13#,LAMBDA(x,TEXTSPLIT(x,{" ",",","?"},,1)))
E23:L25E23=IF(SEQUENCE(,COLUMNS(E17#))=1,E17#,LOWER(E17#))
Dynamic array formulas.
 
text-and-values.xlsx
ABCDEFGHIJKLMN
1single cell
2Äx,xBbxçÇydË,GÓö?2nd solution (Chandoo's idea to use EXACT)
3this we should use it when we have "unusual" letters
4
5for a single cell
6=LET(x,B2,m,MID(x,SEQUENCE(LEN(x)),1),TRIM(TEXTJOIN("",,IF(EXACT(m,UPPER(m))," "&m,m))))
7Äx ,x Bbxç Çyd Ë , G Óö ?
8Note:
9punctuation marks behavior with EXACT
10=EXACT(F11:F15,UPPER(F11:F15))
11?TRUE
12,TRUE
13:TRUE
14-TRUE
15(TRUE
16
17for that reason will have a " " before any delimiter in D7
18
19=TEXTSPLIT(D7,{" ",",","?"},,1)
20ÄxxBbxçÇydËGÓö
21
cap lett. 2
Cell Formulas
RangeFormula
D6,F19,H10D6=FORMULATEXT(D7)
D7D7=LET(x,B2,m,MID(x,SEQUENCE(LEN(x)),1),TRIM(TEXTJOIN("",,IF(EXACT(m,UPPER(m))," "&m,m))))
H11:H15H11=EXACT(F11:F15,UPPER(F11:F15))
F20:L20F20=TEXTSPLIT(D7,{" ",",","?"},,1)
Dynamic array formulas.
 
text-and-values.xlsx
ABCDEFGHIJKLMNOPQRSTUV
1What if the "sentence" contains numbers, or decimal numbers.
2EXACT/UPPER construction(delivers true's) will add a " " space before any digit and any decimal point, like with any punctuation mark (to anything that is not a letter)
3
4=EXACT(B5:B7,UPPER(B5:B7))
51TRUE
63TRUEsample single cell
7.TRUEÀáa35,Ññxx21.03,Òô12.5
8
9old formula (previous formula)
10=LET(x,F7,m,MID(x,SEQUENCE(LEN(x)),1),TRIM(TEXTJOIN("",,IF(EXACT(m,UPPER(m))," "&m,m))))
11Àáa 3 5 , Ññxx 2 1 . 0 3 , Òô 1 2 . 5
12extracting "words" will not keep the integrated numbers together
13=TEXTSPLIT(F11,{" ",","},,1)
14Àáa35Ññxx21.03Òô12.5
15
16amended formula to deal with numbers (digits and decimal points)
17
18=LET(x,F7,m,MID(x,SEQUENCE(LEN(x)),1),TRIM(TEXTJOIN("",,IF(EXACT(m,UPPER(m)),IF(ISNUMBER(--m),"",IF(m=".",""," "))&m,m))))
19Àáa35 , Ññxx21.03 , Òô12.5
20numbers, decimal numbers kept together
21=TEXTSPLIT(F19,{" ",","},,1)
22Àáa35Ññxx21.03Òô12.5
23
cap lett. 3
Cell Formulas
RangeFormula
D4,H21,F18,H13,F10D4=FORMULATEXT(D5)
D5:D7D5=EXACT(B5:B7,UPPER(B5:B7))
F11F11=LET(x,F7,m,MID(x,SEQUENCE(LEN(x)),1),TRIM(TEXTJOIN("",,IF(EXACT(m,UPPER(m))," "&m,m))))
H14:U14,H22:J22H14=TEXTSPLIT(F11,{" ",","},,1)
F19F19=LET(x,F7,m,MID(x,SEQUENCE(LEN(x)),1),TRIM(TEXTJOIN("",,IF(EXACT(m,UPPER(m)),IF(ISNUMBER(--m),"",IF(m=".",""," "))&m,m))))
Dynamic array formulas.
 
text-and-values.xlsx
ABCDEFGHIJKLMNOP
12D array sample,(there are spaces " " and "," here and there that will not affect the results)
2Àáa35Ññxx21.03 Òô12.5Àáa0.35,Ññxx21.03 Òô12.5
3Àáa35.7, Ññxx8.03,Òô12.57 =""
4 Àáa35.8Ññxx0.23Òô12 empty string
5blank
6If we have a formula that works for a single cell,
7with MAP we can apply it to an entire array/range
8
9=MAP(B2:C4,LAMBDA(x,LET(m,MID(x,SEQUENCE(LEN(x)),1),IFERROR(TRIM(TEXTJOIN("",,IF(EXACT(m,UPPER(m)),IF(ISNUMBER(--m),"",IF(m=".",""," "))&m,m))),""))))
10Àáa35 Ññxx21.03 Òô12.5Àáa0.35 , Ññxx21.03 Òô12.5
11Àáa35.7 , Ññxx8.03 , Òô12.57
12Àáa35.8 Ññxx0.23 Òô12single cell formula
13to extract words (no need of IFERROR inside MAP, ATEXTSPILL can handle it)
14
15Àáa35Ññxx21.03Òô12.5
16Àáa0.35Ññxx21.03Òô12.5
17Àáa35.7Ññxx8.03Òô12.57
18
19
20Àáa35.8Ññxx0.23Òô12
21
22E15:
23 =LET( ar,B2:C4, a,TOCOL(IF(ar="","",ar)), ATEXTSPILL(a,LAMBDA(x, LET( m,MID(x,SEQUENCE(LEN(x)),1), y,TRIM(TEXTJOIN("",,IF(EXACT(m,UPPER(m)),IF(ISNUMBER(--m),"",IF(m=".",""," "))&m,m))), TEXTSPLIT(y,{" ",",","?"},,1) ) ) ) )
24
25
26
27
28
29
30
31
32
33
34
35
cap lett. 4
Cell Formulas
RangeFormula
C3,E4C3=""
E3,B9E3=FORMULATEXT(E4)
B10:C12B10=MAP(B2:C4,LAMBDA(x,LET(m,MID(x,SEQUENCE(LEN(x)),1),IFERROR(TRIM(TEXTJOIN("",,IF(EXACT(m,UPPER(m)),IF(ISNUMBER(--m),"",IF(m=".",""," "))&m,m))),""))))
E15:G20E15=LET(ar,B2:C4,a,TOCOL(IF(ar="","",ar)),ATEXTSPILL(a,LAMBDA(x,LET(m,MID(x,SEQUENCE(LEN(x)),1),y,TRIM(TEXTJOIN("",,IF(EXACT(m,UPPER(m)),IF(ISNUMBER(--m),"",IF(m=".",""," "))&m,m))),TEXTSPLIT(y,{" ",",","?"},,1)))))
Dynamic array formulas.
 
text-and-values.xlsx
ABCDEFGHIJKLMN
1single cell sample3rd solution concept, check for letters
2Àáa35Ññxx21.03 Òô12.5 - for a char "l", if exact(lower(l),upper(l)) = false => "l" is a letter
3=> if not(exact(lower(l),upper(i))) = true => "l" is a letter
4
5=MID(B2,SEQUENCE(LEN(B2)),1)
6↓↓check for letters
7↓↓=NOT(EXACT(LOWER(D11#),UPPER(D11#)))
8↓↓↓↓=EXACT(D11#,UPPER(D11#))
9↓↓↓↓↓↓if 1, is letter and is upper
10↓↓↓↓↓↓=H11#*F11#=IF(J11#," "&D11#,D11#)
11ÀTRUETRUE1 À
12áTRUEFALSE0á
13aTRUEFALSE0a
143FALSETRUE03
155FALSETRUE05
16ÑTRUETRUE1 Ñ
17ñTRUEFALSE0ñ
18xTRUEFALSE0x
19xTRUEFALSE0x
202FALSETRUE02
211FALSETRUE01
22.FALSETRUE0.
230FALSETRUE00
243FALSETRUE03
25 FALSETRUE0
26ÒTRUETRUE1 Ò
27ôTRUEFALSE0ô
281FALSETRUE01
292FALSETRUE02
30.FALSETRUE0.
315FALSETRUE05
32
33=TEXTJOIN("",,L11#)
34 Àáa35 Ññxx21.03 Òô12.5
35
cap lett. 5
Cell Formulas
RangeFormula
D5D5=FORMULATEXT(D11)
F7F7=FORMULATEXT(F11)
H8H8=FORMULATEXT(H11)
J10,L10,B33J10=FORMULATEXT(J11)
D11:D31D11=MID(B2,SEQUENCE(LEN(B2)),1)
F11:F31F11=NOT(EXACT(LOWER(D11#),UPPER(D11#)))
H11:H31H11=EXACT(D11#,UPPER(D11#))
J11:J31J11=H11#*F11#
L11:L31L11=IF(J11#," "&D11#,D11#)
B34B34=TEXTJOIN("",,L11#)
Dynamic array formulas.
 
text-and-values.xlsx
ABCDEFGHIJKLMN
1
22D sample
3Àáa35Ññxx21.03 Òô12.5?Àáa0.35,Ññxx21.03 Òô12.5Àáa35Ññxx21.03Òô12.5
4Àáa35.7, Ññxx8.03,Òô12.57 Àáa0.35Ññxx21.03Òô12.5
5 Àáa35.8Ññxx0.23Òô12 ?Àáa35.7Ññxx8.03Òô12.57
6
7
8Àáa35.8Ññxx0.23Òô12
9E3:
10 =LET( ar,B2:C4, a,TOCOL(IF(ar="","",ar)), ATEXTSPILL(a,LAMBDA(x,LET( m,MID(x,SEQUENCE(LEN(x)),1), y,TEXTJOIN("",,IF(NOT(EXACT(LOWER(m),UPPER(m)))*EXACT(m,UPPER(m))," "&m,m)), TEXTSPLIT(y,{" ",",","?"},,1) ) ) ) )
11
12
13
14
15
16
17
18
19
20
21
22
cap lett. 6
Cell Formulas
RangeFormula
E3:G8E3=LET(ar,B3:C5,a,TOCOL(IF(ar="","",ar)),ATEXTSPILL(a,LAMBDA(x,LET(m,MID(x,SEQUENCE(LEN(x)),1),y,TEXTJOIN("",,IF(NOT(EXACT(LOWER(m),UPPER(m)))*EXACT(m,UPPER(m))," "&m,m)),TEXTSPLIT(y,{" ",",","?"},,1)))))
C4C4=""
Dynamic array formulas.
 
For fun, single cell formula alternative to the PQ solution, main subject of the YT.
text-and-values.xlsx
ABCDEFGHIJKLMN
1
2sample, shorter than original raw data in Chandoo's workbooksingle cell formula to replace PQ
3DateCompanyPerson NameRoom numberDateCompanyPerson NameRoom numberText Value
401-Jan-22AvambaAnatole Ridehalgh400801-01-22AvambaAnatole Ridehalgh4008Hotels
501-Jan-22FatzAldrich McKevin200201-01-22FatzAldrich McKevin2002Hotels
601-Jan-22LeexoStanley Hadrill401201-01-22LeexoStanley Hadrill4012Hotels
7Hotels01-01-22RhyzioLyndell Tice1006Booking
801-Jan-22RhyzioLyndell Tice100601-01-22EadelBroderic Handscombe3015Booking
901-Jan-22EadelBroderic Handscombe301501-01-22OozzDeina Harwin2005Booking
1001-Jan-22OozzDeina Harwin200501-01-22InnotypeBenyamin Crocetti2001Booking
1101-Jan-22InnotypeBenyamin Crocetti200101-01-22Thea Melan5006Booking
1201-Jan-22Thea Melan500601-01-22Alexei Kneale3002Booking
1301-Jan-22Alexei Kneale300201-01-22JayoTate Manntschke3014Booking
1401-Jan-22JayoTate Manntschke301401-01-22Eudora Nettle6003Cleartrip
15Booking01-01-22RiffpediaElianore Vigar3002Cleartrip
1601-Jan-22Eudora Nettle600301-01-22TazzAlonso Mundee4006Cleartrip
1701-Jan-22RiffpediaElianore Vigar300201-01-22BrowsezoomYsabel Lordon6003Hotels
1801-Jan-22TazzAlonso Mundee400601-01-22SkinteRaff Verecker3012Hotels
19Cleartrip01-01-22Drusi Loomis2005Hotels
2001-Jan-22BrowsezoomYsabel Lordon600301-01-22TwitterlistAndrea Humpatch4005Hotels
2101-Jan-22SkinteRaff Verecker301201-01-22ShuffletagCammy Curle2016Expedia
2201-Jan-22Drusi Loomis200501-01-22GebaHowey Oseman6001Expedia
2301-Jan-22TwitterlistAndrea Humpatch400501-01-22Kendall Skynner6003Expedia
24Hotels01-01-22FlipopiaPrince Coppenhall2002Booking
2501-Jan-22ShuffletagCammy Curle201601-01-22TopicblabNoni Tarbett1012Booking
2601-Jan-22GebaHowey Oseman600101-01-22FeedmixBondon Tuny3007Booking
2701-Jan-22Kendall Skynner600301-01-22SkynoodleAndros Cathcart1008Booking
28Expedia01-01-22MitaAubert Racher4004Travel Agent 007
2901-Jan-22FlipopiaPrince Coppenhall200201-01-22SkinixCurcio Lewis3008Travel Agent 007
3001-Jan-22TopicblabNoni Tarbett101201-01-22AimbuWeider Brookz1001Travel Agent 007
3101-Jan-22FeedmixBondon Tuny300701-01-22BabblestormAlric Reeder7001Travel Agent 007
3201-Jan-22SkynoodleAndros Cathcart100801-01-22JayoMelany Brimblecombe3010Travel Agent 007
33Booking01-01-22QuinuArt Giannotti3013Travel Agent 007
3401-Jan-22MitaAubert Racher400401-01-22DynazzyEricha MacBain4002Expedia
3501-Jan-22SkinixCurcio Lewis300801-01-22TagtuneScarlett Berthel2001Expedia
3601-Jan-22AimbuWeider Brookz100101-01-22Brana Stovin3008Expedia
3701-Jan-22BabblestormAlric Reeder700101-01-22KimiaLottie Barnsdall2014Expedia
3801-Jan-22JayoMelany Brimblecombe301001-01-22CentizuFaydra Hulland5006Expedia
3901-Jan-22QuinuArt Giannotti301301-01-22MuxoFelice Kramer4002Expedia
40Travel Agent 00701-01-22DynaboxDeane Gemson5005Expedia
4101-Jan-22DynazzyEricha MacBain400201-01-22SkalithWillie Norree3002Expedia
4201-Jan-22TagtuneScarlett Berthel200101-01-22TagchatAlmira Bartolomeotti2004Expedia
4301-Jan-22Brana Stovin300801-01-22BuzzdogSharona Ferreres4012Travel Agent 007
4401-Jan-22KimiaLottie Barnsdall201401-01-22ZavaIlaire Gaynes1013Travel Agent 007
4501-Jan-22CentizuFaydra Hulland500601-01-22Prinz Rohan7001Travel Agent 007
4601-Jan-22MuxoFelice Kramer400201-01-22NtagsCorny Madill3002Booking
4701-Jan-22DynaboxDeane Gemson500501-01-22YouspanYasmin Snelgar3012Travel Agent 007
4801-Jan-22SkalithWillie Norree300201-01-22SkyvuSherlock Hyland6001Travel Agent 007
4901-Jan-22TagchatAlmira Bartolomeotti200401-01-22QuinuKalindi Shaughnessy6003Travel Agent 007
50Expedia01-01-22TwitterlistLauretta Stoke4004Travel Agent 007
5101-Jan-22BuzzdogSharona Ferreres401201-01-22BrightdogLucie Jewiss2009Hotels
5201-Jan-22ZavaIlaire Gaynes101301-01-22ShufflebeatDorita Boulger6005Hotels
5301-Jan-22Prinz Rohan700101-01-22FivechatOrsola Cowdery4001Hotels
54Travel Agent 00701-01-22TopicloungeLilah Attryde1005Hotels
5501-Jan-22NtagsCorny Madill300201-01-22YouopiaAlley Pyer2002Hotels
56Booking
5701-Jan-22YouspanYasmin Snelgar3012
5801-Jan-22SkyvuSherlock Hyland6001
5901-Jan-22QuinuKalindi Shaughnessy6003
6001-Jan-22TwitterlistLauretta Stoke4004
61Travel Agent 007
6201-Jan-22BrightdogLucie Jewiss2009
6301-Jan-22ShufflebeatDorita Boulger6005
6401-Jan-22FivechatOrsola Cowdery4001
6501-Jan-22TopicloungeLilah Attryde1005
6601-Jan-22YouopiaAlley Pyer2002
67Hotels
68
69F3 :
70=LET(ar,A4:D67,h,A3:D3,d,A4:A67,f,D4:D67,t,"Text Value", a,IF(ar="","",ar),s,SEQUENCE(ROWS(a)), x,f="", k,XLOOKUP(s,FILTER(s,x),FILTER(d,x),,1), IFNA(VSTACK(h,FILTER(HSTACK(a,k),NOT(x))),t))
71
no PQ
Cell Formulas
RangeFormula
F3:J55F3=LET(ar,A4:D67,h,A3:D3,d,A4:A67,f,D4:D67,t,"Text Value", a,IF(ar="","",ar),s,SEQUENCE(ROWS(a)), x,f="", k,XLOOKUP(s,FILTER(s,x),FILTER(d,x),,1), IFNA(VSTACK(h,FILTER(HSTACK(a,k),NOT(x))),t))
A70A70=FORMULATEXT(F3)
Dynamic array formulas.
 

Forum statistics

Threads
1,215,046
Messages
6,122,852
Members
449,096
Latest member
Erald

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top