Creating new rows from a minimum value and count

ScruffyW1lf

New Member
Joined
Jun 1, 2023
Messages
11
Office Version
  1. 365
Platform
  1. Windows
Hi, have a large number of records that includer a reference, a minimum value and a maximum value e.g. 0 (min) 800 (max). The minimum and maximum values vary per record but are all wholly divisible by 10. I wish to break down the record into a series of new records so that e.g. a record min= 0, max = 800 is now a series of records with the same reference as the original but 0-10,10-20, 20-30 until it reaches the max value - in this case 790-800. I have a count already set up against each original record so know how may "sub" records to expect. I am assumin this will need some iterative VBA or similar, but haven't a clue how to do it. Anyway care to teach this old dog?
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Perhaps the below will help:
Book1
ABCDEFG
1ReferenceMinMaxCountReferenceBracket
212305051230-10
345650100512310-20
47891005004012320-30
512330-40
612340-50
745650-60
845660-70
945670-80
1045680-90
1145690-100
12789100-110
13789110-120
14789120-130
15789130-140
16789140-150
17789150-160
18789160-170
19789170-180
20789180-190
21789190-200
22789200-210
23789210-220
24789220-230
25789230-240
26789240-250
27789250-260
28789260-270
29789270-280
30789280-290
31789290-300
32789300-310
33789310-320
34789320-330
35789330-340
36789340-350
37789350-360
38789360-370
39789370-380
40789380-390
41789390-400
42789400-410
43789410-420
44789420-430
45789430-440
46789440-450
47789450-460
48789460-470
49789470-480
50789480-490
51789490-500
Sheet1
Cell Formulas
RangeFormula
F2:G51F2=LET(startRange,B2:B4,countRange,D2:D4,ref,A2:A4, rpt,TOCOL(IF(SEQUENCE(,MAX(countRange))<=countRange,ref,#N/A),3), cumTotal,MMULT(IF(ROW(countRange)>TRANSPOSE(ROW(countRange)),1,0),countRange), rowSeq,SEQUENCE(SUM(countRange),1,0,1), totCount,SUM(countRange), modRow,MOD(rowSeq,totCount), series,MATCH(modRow,cumTotal), startValue,INDEX(startRange,series), subtract,INDEX(cumTotal,series), result,startValue+(rowSeq*10)-(subtract*10), HSTACK(rpt,result & "-" & result+10))
D2:D4D2=(C2-B2)/10
Dynamic array formulas.


If the data is very large then it might be better to wait for a VBA solution.

Inspiration came from the below link:
Incrementing multiple sequence of numbers in single excel column
 
Upvote 0
Perhaps the below will help:
Book1
ABCDEFG
1ReferenceMinMaxCountReferenceBracket
212305051230-10
345650100512310-20
47891005004012320-30
512330-40
612340-50
745650-60
845660-70
945670-80
1045680-90
1145690-100
12789100-110
13789110-120
14789120-130
15789130-140
16789140-150
17789150-160
18789160-170
19789170-180
20789180-190
21789190-200
22789200-210
23789210-220
24789220-230
25789230-240
26789240-250
27789250-260
28789260-270
29789270-280
30789280-290
31789290-300
32789300-310
33789310-320
34789320-330
35789330-340
36789340-350
37789350-360
38789360-370
39789370-380
40789380-390
41789390-400
42789400-410
43789410-420
44789420-430
45789430-440
46789440-450
47789450-460
48789460-470
49789470-480
50789480-490
51789490-500
Sheet1
Cell Formulas
RangeFormula
F2:G51F2=LET(startRange,B2:B4,countRange,D2:D4,ref,A2:A4, rpt,TOCOL(IF(SEQUENCE(,MAX(countRange))<=countRange,ref,#N/A),3), cumTotal,MMULT(IF(ROW(countRange)>TRANSPOSE(ROW(countRange)),1,0),countRange), rowSeq,SEQUENCE(SUM(countRange),1,0,1), totCount,SUM(countRange), modRow,MOD(rowSeq,totCount), series,MATCH(modRow,cumTotal), startValue,INDEX(startRange,series), subtract,INDEX(cumTotal,series), result,startValue+(rowSeq*10)-(subtract*10), HSTACK(rpt,result & "-" & result+10))
D2:D4D2=(C2-B2)/10
Dynamic array formulas.


If the data is very large then it might be better to wait for a VBA solution.

Inspiration came from the below link:
Incrementing multiple sequence of numbers in single excel column
Wow! Didn't expect a solution as an equation but would much prefer it that way - although there are about 2000 (and counting) lines to convert which will likely result in considerably more records so maybe this might send my laptop into panic mode. Absolutely intriguing though and I will give it a try. The resultant range in column G is obviously text but the start value alone is far more useful to me and as a value, so I assume the HSTACK entry is reduced to (rpt,result) ?
 
Upvote 0
Yes, so the below would give you the brackets as numbers in seperate columns:
Book1
ABCDEFGH
1ReferenceMinMaxCountReferencelBracketuBracket
21230505123010
34565010051231020
4789100500401232030
51233040
61234050
74565060
84566070
94567080
104568090
1145690100
12789100110
13789110120
14789120130
15789130140
16789140150
17789150160
18789160170
19789170180
20789180190
21789190200
22789200210
23789210220
24789220230
25789230240
26789240250
27789250260
28789260270
29789270280
30789280290
31789290300
32789300310
33789310320
34789320330
35789330340
36789340350
37789350360
38789360370
39789370380
40789380390
41789390400
42789400410
43789410420
44789420430
45789430440
46789440450
47789450460
48789460470
49789470480
50789480490
51789490500
Sheet1
Cell Formulas
RangeFormula
F2:H51F2=LET(startRange,B2:B4,countRange,D2:D4,ref,A2:A4, rpt,TOCOL(IF(SEQUENCE(,MAX(countRange))<=countRange,ref,#N/A),3), cumTotal,MMULT(IF(ROW(countRange)>TRANSPOSE(ROW(countRange)),1,0),countRange), rowSeq,SEQUENCE(SUM(countRange),1,0,1), totCount,SUM(countRange), modRow,MOD(rowSeq,totCount), series,MATCH(modRow,cumTotal), startValue,INDEX(startRange,series), subtract,INDEX(cumTotal,series), result,startValue+(rowSeq*10)-(subtract*10), HSTACK(rpt,result,result+10))
D2:D4D2=(C2-B2)/10
Dynamic array formulas.
 
Upvote 0
Perhaps the below will help:
Book1
ABCDEFG
1ReferenceMinMaxCountReferenceBracket
212305051230-10
345650100512310-20
47891005004012320-30
512330-40
612340-50
745650-60
845660-70
945670-80
1045680-90
1145690-100
12789100-110
13789110-120
14789120-130
15789130-140
16789140-150
17789150-160
18789160-170
19789170-180
20789180-190
21789190-200
22789200-210
23789210-220
24789220-230
25789230-240
26789240-250
27789250-260
28789260-270
29789270-280
30789280-290
31789290-300
32789300-310
33789310-320
34789320-330
35789330-340
36789340-350
37789350-360
38789360-370
39789370-380
40789380-390
41789390-400
42789400-410
43789410-420
44789420-430
45789430-440
46789440-450
47789450-460
48789460-470
49789470-480
50789480-490
51789490-500
Sheet1
Cell Formulas
RangeFormula
F2:G51F2=LET(startRange,B2:B4,countRange,D2:D4,ref,A2:A4, rpt,TOCOL(IF(SEQUENCE(,MAX(countRange))<=countRange,ref,#N/A),3), cumTotal,MMULT(IF(ROW(countRange)>TRANSPOSE(ROW(countRange)),1,0),countRange), rowSeq,SEQUENCE(SUM(countRange),1,0,1), totCount,SUM(countRange), modRow,MOD(rowSeq,totCount), series,MATCH(modRow,cumTotal), startValue,INDEX(startRange,series), subtract,INDEX(cumTotal,series), result,startValue+(rowSeq*10)-(subtract*10), HSTACK(rpt,result & "-" & result+10))
D2:D4D2=(C2-B2)/10
Dynamic array formulas.


If the data is very large then it might be better to wait for a VBA solution.

Inspiration came from the below link:
Incrementing multiple sequence of numbers in single excel column
Well, I'm incredibly impressed and much appreciate your solution. I will certainly give this a go tomorrow morning. I guess it'd be wise for me to see whether a VBA solution is offered up too, just in case my laptop does fall over as it often does with excessively large amounts of data and equations.
 
Upvote 0
If you sum the count column that will tell you how many rows the formula will create.
 
Upvote 0
If you sum the count column that will tell you how many rows the formula will create.
Yes, of course it will. 16643 expected so far from1286 base records. It could be a thumb-twiddling morning whilst calculating or not. Lots of coffee and feet up on the desk planned.
 
Upvote 0
I've finally got around to applying the equation you provided - just noticed there is a #N/A embedded in line 2. Given that my first attempt with tweaks to the ranges are resulting in a #NAME? failure, I am assuming the #N/A is responsible?
 
Upvote 0
The #N/A is suposed to be in the formula. It is used to weed out information we don't want. It basically creates an error that is then ignored due to the 3 on the end of the TOCOL function.
That "," is not stray, before the comma is rows, after the comma is columns. I have left rows blank as it will default to 1.

I have just tested the formula with data that amounts to 69,000 rows. This is with my data.

Do you have anything in the data that is different to the demo i made up?
Are you able to use the XL2BB addin to display some of the data you are working with?
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,323
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