Results 1 to 5 of 5

Macro to generate all numbers between two numbers

Threaded View

  1. #1
    Registered User
    Join Date
    06-24-2008
    Posts
    23

    Macro to generate all numbers between two numbers

    Hi everyone,

    I was able to cobble together a macro from another posting on another site and it works if I only put in one starting and ending number, but if I do more than one it gives me everything between all the numbers. What I want is to be able to put in a starting and ending number on multiple lines and for it to give me the number between the start and end per line. At the bottom of the post is my current code.

    For example if I put in the following:

    Starting Ending
    850 853
    900 903


    I get the following back:

    850
    851 This part is what I want
    852
    853
    everything from 853 to 899
    900
    901
    902
    903


    What I want to get is:

    850
    851
    852
    853
    900
    901
    902
    903


    Then lastly I'm also looking for macro language to output another string where each number is output separated by a comma.


    Thoughts? I tried a loop but with no luck.


    
    
    Sub Numbers()
        Dim vStop, vStart
        
        With WorksheetFunction
            vStart = .Min(Sheet1.Range("A2:B100"))
            vStop = .Max(Sheet1.Range("A2:B100"))
        End With
         
        With Sheets("Output")
            .Range("A2") = vStart
            .Range("A2:A65536").DataSeries Step:=1, Stop:=vStop
        End With
        
    End Sub
    Last edited by XL2008; 09-17-2015 at 01:41 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 7
    Last Post: 11-05-2014, 04:23 AM
  2. Is there any script that I generate 6 numbers of these numbers from the list?
    By dragon66 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-15-2014, 01:22 PM
  3. Replies: 1
    Last Post: 10-16-2013, 02:46 PM
  4. Macro Generate Numbers in Sequential Order
    By Rem0ram in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-09-2013, 08:30 AM
  5. Macro to generate list of numbers to link only one series to a key
    By cgkmal in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-06-2012, 01:27 AM
  6. Replies: 4
    Last Post: 10-11-2010, 05:13 AM
  7. Random numbers to generate amount between two numbers
    By maverickbv80 in forum Excel General
    Replies: 2
    Last Post: 09-08-2010, 11:21 AM

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