+ Reply to Thread
Results 1 to 4 of 4

Autofill range with random integers between two cells

  1. #1
    Registered User
    Join Date
    05-24-2012
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    2

    Autofill range with random integers between two cells

    If I have number 1 in A1 and number 10 in B1 how do i get sequential range in C1
    Example C1 would have 1;2;3;4; and so on

    Thank you,
    Walter

  2. #2
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Autofill range with random integers between two cells

    Hi Walter,

    welcome to the forum.
    If you are doing this to consider / use a dynamic range where the reference starts from 1 through 10, you can use a dynamic name created with the help of Offset and Match functions.. share your purpose so that I can guide you accordingly. thanks.

    Regards,
    DILIPandey

    <click on below 'star' if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), dilipandey@gmail.com

  3. #3
    Registered User
    Join Date
    05-24-2012
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Autofill range with random integers between two cells

    I have a data base where I have 2 fields (beginning number and end number) I will have another field with range field where the range would be specified.
    Example A1 has number 1 and B1 has 10 and C1 will have 1;2;3;4;5;6;7;8;9;10 in one cell. What would be the formula to do this?
    Thanks again!

  4. #4
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Autofill range with random integers between two cells

    Walter01,

    Welcome to the forum!
    Attached is an example workbook based on the criteria you described. It does have headers, so the actual data starts in row 2. In cell C2 and copied down is this formula:
    Please Login or Register  to view this content.


    FillNumbers is a UDF (User Defined Function) that has the following code in a standard module:
    Please Login or Register  to view this content.


    How to use a UDF:
    1. Make a copy of the workbook the macro will be run on
      • Always run new code on a workbook copy, just in case the code doesn't run smoothly
      • This is especially true of any code that deletes anything
    2. In the copied workbook, press ALT+F11 to open the Visual Basic Editor
    3. Insert | Module
    4. Copy the provided code and paste into the module
    5. Close the Visual Basic Editor
    6. In a cell that will contain the formula, put =UDFName(UDFArgument1, UDFArgument 2, etc...)

    I named this UDF FillNumbers
    It has 3 arguments:
    The first argument is the StartNumber (what number to start the fill with)
    The second argument is the FinalNumber (what number to end the fill with)
    The third argument is the delimiter used. This is an optional argument. If omitted, it will use a semicolon by default.
    Attached Files Attached Files
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1