enumerate numbers between two cells

blicop

New Member
Joined
Aug 9, 2011
Messages
18
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I need help with this example:
Cell A1 has a value of 1
Cell B1 has a value of 10

On C1 I would like to have 1, 2, 3 , 4, 5, 6, 7, 8, 9, 10

Any help would be highly appreciated.

Thanks!

Basil
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
With an extra function, called a User Defined Function:

Code:
Function Enumeration(iFirst As Integer, iLast As Integer) As String
    For i = iFirst To iLast
        Enumeration = Enumeration & ", " & i
    Next
    Enumeration = Mid(Enumeration, 3)
End Function

Add the function to a normal module in your file, and then in any worksheet and any cell, you can use:

=Enumeration(A1,B1)
 
Upvote 0
Here is a UDF (user defined function) that you can use...

Code:
Function NumSeries(StartNumber As Long, EndNumber As Long) As String
  Dim X As Long
  For X = StartNumber To EndNumber
    NumSeries = NumSeries & ", " & X
  Next
  NumSeries = Mid(NumSeries, 3)
End Function
For you example, you would simply use this formula...

=NumSeries(A1,B1)

You can install the UDF by pressing ALT+F11 to go into the VB editor, clicking Insert/Module from it menu bar once there, and then copy/paste the above code into the code window that opened up. That's it... go back to any worksheet and use the UDF as shown above.
 
Last edited:
Upvote 0
it works! very cool!

now if only vlookup can be used for the enumerated numbers...
 
Upvote 0
now if only vlookup can be used for the enumerated numbers...

Well, having multiple numbers or entries in 1 cell is never a good idea in Excel. Did you know how many cells you have on 1 worksheet?
 
Upvote 0
not sure if you meant rows - which is 45 in this case..
 
Upvote 0
An Excel 2007/2010 worksheet has 1048576 rows. Prior versions had 65536 rows.

Why do you have only 45 rows? :-)
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,681
Members
452,937
Latest member
Bhg1984

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