Convert numbers into intervals

boboivan

Board Regular
Joined
Feb 18, 2013
Messages
68
Hi guys!


Please let me know if I can convert a particular number (e.g. 5) into an interval (1-5) and if I can count them as follows:


Column M Column N
(Number of pages) (Number interval)
2 1-2
5 3-7
3 8-10
... ...


Thanks!
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
you have to specify your intervals - ( or their bounds ) then plug in any number as parameter to see the interval.
for example.

x = 2
lowB = x - 5
upB = x + 5

so number 2, would be in between -3 and 7
 
Upvote 0
you have to specify your intervals - ( or their bounds ) then plug in any number as parameter to see the interval.
for example.

x = 2
lowB = x - 5
upB = x + 5

so number 2, would be in between -3 and 7

Ok, sorry for being so misleading. The point is, every time I fill in a cell in column M with a number (e.g. 2), automatically that number to be converted into an interval in column N (format like "1-2") and count with the next row converted as well in this format.
Column LColumn MColumn N
Row 2PaperworkNo. of pagesPages interval
Row 3e.g. 21-2
Row 4e.g. 53-7
Row 5e.g. 48-11
Row 6Total11

<tbody>
</tbody>

Thank you!
 
Upvote 0
A = M
B = N
first row =1&"-"&A1
2nd til 9 =RIGHT(B1,1)+1&"-"& RIGHT(B1,1)+1 +A2
10 til 99 =RIGHT(B3,2)+1&"-"& RIGHT(B3,2)+1 +A4

then obviously for each digit do RIGHT(n, 3 etc )
 
Upvote 0
I'd do it like this:

1) establish a lookup table with the minimum value for each interval and the corresponding interval lable:



then return the value from the table with a vlookup of the form:

=VLOOKUP(A5,$A$1:$B$4,2)

...where a5 is your total pages so far count, and $a$1:$b$4 is your lookup table
 
Upvote 0
Thank you very much PaddyD but I need to count every row, not just to copy. Any idea how to do that?
 
Upvote 0
@ mehowski
Thanks maestro, great job!
I still I have a problem when in the second row I'll add a 2 or 3 digits number and in the third a 1 digit number. Any idea about it?
Also, I don't think it's needed to add +1 in the formula.
"=RIGHT(B1;1)+1&"-"& RIGHT(B1;1)+A2" will do the job.
 
Last edited:
Upvote 0
Try this, assuming your data starts in M2 & N2 - You only need to enter the formula in N3 and drag down

Excel 2010
MN
1PagesIntervals
221-2
353-7
438-10
5411-14
62515-39
75540-94
81295-106
91000107-1106

<colgroup><col style="width: 25pxpx"><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet4

Worksheet Formulas
CellFormula
N2=1&"-"&M2+0
N3=SUBSTITUTE(RIGHT(N2,FIND("-",N2)),"-","")+1&"-"&SUM($M$2:M3)
N4
=SUBSTITUTE(RIGHT(N3,FIND("-",N3)),"-","")+1&"-"&SUM($M$2:M4)
N5=SUBSTITUTE(RIGHT(N4,FIND("-",N4)),"-","")+1&"-"&SUM($M$2:M5)
N6=SUBSTITUTE(RIGHT(N5,FIND("-",N5)),"-","")+1&"-"&SUM($M$2:M6)
N7=SUBSTITUTE(RIGHT(N6,FIND("-",N6)),"-","")+1&"-"&SUM($M$2:M7)
N8=SUBSTITUTE(RIGHT(N7,FIND("-",N7)),"-","")+1&"-"&SUM($M$2:M8)
N9=SUBSTITUTE(RIGHT(N8,FIND("-",N8)),"-","")+1&"-"&SUM($M$2:M9)

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>
 
Last edited:
Upvote 0
A = M
B = N
first row =1&"-"&A1
2nd til 9 =RIGHT(B1,1)+1&"-"& RIGHT(B1,1)+1 +A2
10 til 99 =RIGHT(B3,2)+1&"-"& RIGHT(B3,2)+1 +A4

then obviously for each digit do RIGHT(n, 3 etc )

Thanks maestro, great job!
I still I have a problem when in the second row I'll add a 2 or 3 digits number and in the third a 1 digit number. Any idea about it?
Also, I don't think it's needed to add +1 in the formula.
"=RIGHT(B1;1)+1&"-"& RIGHT(B1;1)+A2" will do the job.
 
Upvote 0
Try this, assuming your data starts in M2 & N2 - You only need to enter the formula in N3 and drag down

Excel 2010
MN
1PagesIntervals
221-2
353-7
438-10
5411-14
62515-39
75540-94
81295-106
91000107-1106

<tbody>
</tbody>
Sheet4

Worksheet Formulas
CellFormula
N2=1&"-"&M2+0
N3=SUBSTITUTE(RIGHT(N2,FIND("-",N2)),"-","")+1&"-"&SUM($M$2:M3)
N4=SUBSTITUTE(RIGHT(N3,FIND("-",N3)),"-","")+1&"-"&SUM($M$2:M4)
N5=SUBSTITUTE(RIGHT(N4,FIND("-",N4)),"-","")+1&"-"&SUM($M$2:M5)
N6=SUBSTITUTE(RIGHT(N5,FIND("-",N5)),"-","")+1&"-"&SUM($M$2:M6)
N7=SUBSTITUTE(RIGHT(N6,FIND("-",N6)),"-","")+1&"-"&SUM($M$2:M7)
N8=SUBSTITUTE(RIGHT(N7,FIND("-",N7)),"-","")+1&"-"&SUM($M$2:M8)
N9=SUBSTITUTE(RIGHT(N8,FIND("-",N8)),"-","")+1&"-"&SUM($M$2:M9)

<tbody>
</tbody>

<tbody>
</tbody>

This is exactly what I need. Thank you very much smart man from the beautiful Edinburgh!
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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