textjoin high and low of a sequence

ExcelNewbie2020

Active Member
Joined
Dec 3, 2020
Messages
343
Office Version
  1. 365
Platform
  1. Windows
sirs, what formula to use to textjoin the high and low of a sequence. thank you

Excel.xlsm
AB
1SOURCERESULT
26565-60
364
463
562
661
760
85555
95050-48
1049
1148
123535-34
1334
142929-23
1528
1627
1726
1825
1924
2023
Sheet9
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Upvote 0
ARRAY formula in B2
Excel Formula:
=IF(LARGE(IF($A$2:$A$16<CEILING($A2,10),$A$2:$A$16,""),1)=$A2,$A2&"-"&SMALL(IF($A$2:$A$16>FLOOR($A2,10),$A$2:$A$16,""),1),"")
copied down.

SourseFormula
6565-61
64
63
62
61
5858-53
55
53
4747-42
46
44
42
3636-33
34
33
 
Upvote 0
it did worked.. thanks..
You're welcome. Thanks for the confirmation. :)

.. can it be done by an array formula?
It is an array formula.

ARRAY formula in B2
Excel Formula:
=IF(LARGE(IF($A$2:$A$16<CEILING($A2,10),$A$2:$A$16,""),1)=$A2,$A2&"-"&SMALL(IF($A$2:$A$16>FLOOR($A2,10),$A$2:$A$16,""),1),"")
copied down.
Only thing is that your formula applied to the OP's sample data does not produce the results requested.
 
Upvote 0
by the way, i am just curious..can it be done by an array formula?
Do you mean a spill formula? Maybe:

Book1
AB
1SOURCERESULT
26565-60
364
463
562
661
760
85555
95050-48
1049
1148
123535-34
1334
142929-23
1528
1627
1726
1825
1924
2023
21
Sheet5
Cell Formulas
RangeFormula
B2:B20B2=LET(d,A2:A20,b,A1:A19,a,A3:A21,st,IF(IFERROR(d<b-1,1),d),en,IF(d>a+1,d),sc,SEQUENCE(COUNT(st)),stl,LARGE(st,sc),enl,LARGE(en,sc),z,INDEX(enl,MATCH(d,stl,0)),IF(ISNUMBER(MATCH(d,st,0)),IF(d=z,d,d&"-"&z),""))
Dynamic array formulas.


This should work, with a lot of caveats: all integers, no repeats, strictly decreasing.
 
Upvote 1
it did worked.. thanks..
Looking again, I see that my earlier formula would fail if the last value in the range was not part of the sequence above. For example if A20 was, say, 16. See col D below
The correction is in column C

Do you mean a spill formula?
If Eric is right about what you were asking, then the adaptation of my method is in col B.

24 03 02.xlsm
ABCD
1SOURCESpillCorrectionOriginal
26565-6065-6065-60
364  
463  
562  
661  
760  
855555555
95050-4850-4850-48
1049  
1148  
123535-3435-3435-34
1334  
142929-2429-2429-24
1528  
1627  
1726  
1825  
1924  
20161616#N/A
21
High Low
Cell Formulas
RangeFormula
B2:B20B2=LET(a,A2:A20,E,INDEX(a,ROWS(a)),F,OFFSET(E,1,0),BYROW(a,LAMBDA(r,IF(r=N(OFFSET(r,-1,0))-1,"",LET(n,IFNA(MATCH(TRUE,r:E-OFFSET(r,1,0):F<>1,0),1),r&IF(n=1,"",-(r-n+1)))))))
C2:C20C2=IF(A2=N(A1)-1,"",LET(n,IFNA(MATCH(TRUE,(A2:A$20-A3:A$21)<>1,0),1),A2&IF(n=1,"",-(A2-n+1))))
D2:D20D2=IF(A2=N(A1)-1,"",LET(n,MATCH(TRUE,(A2:A$20-A3:A$21)<>1,0),A2&IF(n=1,"",-(A2-n+1))))
Dynamic array formulas.
 
Upvote 0
Solution
Looking again, I see that my earlier formula would fail if the last value in the range was not part of the sequence above. For example if A20 was, say, 16. See col D below
The correction is in column C


If Eric is right about what you were asking, then the adaptation of my method is in col B.

24 03 02.xlsm
ABCD
1SOURCESpillCorrectionOriginal
26565-6065-6065-60
364  
463  
562  
661  
760  
855555555
95050-4850-4850-48
1049  
1148  
123535-3435-3435-34
1334  
142929-2429-2429-24
1528  
1627  
1726  
1825  
1924  
20161616#N/A
21
High Low
Cell Formulas
RangeFormula
B2:B20B2=LET(a,A2:A20,E,INDEX(a,ROWS(a)),F,OFFSET(E,1,0),BYROW(a,LAMBDA(r,IF(r=N(OFFSET(r,-1,0))-1,"",LET(n,IFNA(MATCH(TRUE,r:E-OFFSET(r,1,0):F<>1,0),1),r&IF(n=1,"",-(r-n+1)))))))
C2:C20C2=IF(A2=N(A1)-1,"",LET(n,IFNA(MATCH(TRUE,(A2:A$20-A3:A$21)<>1,0),1),A2&IF(n=1,"",-(A2-n+1))))
D2:D20D2=IF(A2=N(A1)-1,"",LET(n,MATCH(TRUE,(A2:A$20-A3:A$21)<>1,0),A2&IF(n=1,"",-(A2-n+1))))
Dynamic array formulas.
yes, i mean a spill array formula.. thanks man.. really appreciated
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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