List numbers between two numbers

WESTERNWALL

Board Regular
Joined
Oct 8, 2002
Messages
204
Office Version
  1. 365
Platform
  1. MacOS
Sounds weird, doesn't it?

I have two numbers, for example 1-5, 40-150, etc. I would like to list the numbers between those 1 to 5 or 40 to 150 including the first and the last, either somewhere else on the worksheet or on another tab. Is that possible?

Thanks
 
Hi!

If you have the data into A1 to Bx, Column A: Start, Column B: End, You must try this macro:

Code:
Sub ExpandSeries()
    Dim RR$, R&, C As Range    
    Application.ScreenUpdating = 0
    R = Range("A1").CurrentRegion.Rows.Count
    RR = "D1" ' Place to Write Results
    
    With Range(RR)
        .CurrentRegion.ClearContents ' Clear previous Results
        .Resize(2, R) = Application.Transpose(Range("A1").CurrentRegion)
        .Offset(2).Resize(, R) = "Series"
        .Offset(3).Resize(, R) = .Resize(, R).Value
        For Each C In .Offset(3).Resize(, R)
            C.DataSeries Rowcol:=xlColumns, Type:=xlLinear, Step:=1, Stop:=C.Offset(-2)
        Next C
        .CurrentRegion.Columns.AutoFit
    End With
    Application.ScreenUpdating = 1
End Sub
 
Upvote 0

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Useful,

A very nice solution!!!

May I point out the need for one minor correction.........

Rich (BB code):
Sub Fill()    [A4] = [A1].Value
    ato = [B1].Value
    [B4] = [A2].Value
    bto = [B2].Value
    [C4] = [A3].Value
    cto = [B3].Value
    [A4].DataSeries Rowcol:=xlColumns, Type:=xlLinear, Step:=1, Stop:=ato
    [B4].DataSeries Rowcol:=xlColumns, Type:=xlLinear, Step:=1, Stop:=bto
    [C4].DataSeries Rowcol:=xlColumns, Type:=xlLinear, Step:=1, Stop:=cto
End Sub
Hello Snakehips!
thank you for correction i missed that while copy paste :)
 
Upvote 0

Forum statistics

Threads
1,216,727
Messages
6,132,354
Members
449,720
Latest member
NJOO7

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