+ Reply to Thread
Results 1 to 4 of 4

generate numbers with macros

  1. #1
    Registered User
    Join Date
    05-26-2014
    Posts
    3

    generate numbers with macros

    Hi,

    I have these numbers 1,5,10,15,20,25,30,35,40

    I have to generate 3 numbers in a row like this

    1,5,10
    1,10,15
    1,15,20
    1,25,20 and so on..........

    to explain the above series(1,5,10,15,20,25,30,35,40) has 10 different numbers, I have to form many row with just 3 numbers in one row. Like that need all the combination of numbers with above 10 number with 3 numbers in a row.

    So there could be many rows if we generate the numbers, can some one help to write a excel macro to generate these numbers

    thanks
    vbax

  2. #2
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: generate numbers with macros

    Firstly (1,5,10,15,20,25,30,35,40) is 9 numbers not 10. Is 45 to be included?


    If I understand correctly you want every combination of 3 numbers from these 10. That's 10 x 9 x 8 = 720 combinations assuming there's no repeats. Is this correct?

    I assume the combination 1,5,10 is the same as 5,10,1 and 1,10,5 etc. You only want this displayed once I assume?
    Happy with my advice? Click on the * reputation button below

  3. #3
    Registered User
    Join Date
    05-26-2014
    Posts
    3

    Re: generate numbers with macros

    Quote Originally Posted by Crooza View Post
    Firstly (1,5,10,15,20,25,30,35,40) is 9 numbers not 10. Is 45 to be included?

    Yes include 10 also.

    If I understand correctly you want every combination of 3 numbers from these 10. That's 10 x 9 x 8 = 720 combinations assuming there's no repeats. Is this correct?
    Why did you say its 10*9*8 ?
    Yes and No for Repeats, I can have with repeats and without repeats.

    I assume the combination 1,5,10 is the same as 5,10,1 and 1,10,5 etc. You only want this displayed once I assume?
    Again yes and No for combinations, I can have with combinations and without combinations.

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: generate numbers with macros

    The Macro for this is quite simple.

    I created a User Defined Function instead.

    I will post both.

    First the UDF.

    Paste the UDF into a macro module

    Then Type your numbers into a cell eg A8

    then type this formula into Say C12

    =Combinations(A$8) then fill down and up



    Please Login or Register  to view this content.

    This Macro does the same thing but the Number List must be in A1 and the output is in column B

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by mehmetcik; 05-14-2016 at 02:36 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

+ Reply to Thread

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: 05-07-2016, 10:34 PM
  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. Macros to generate all possible combinations
    By Nnamdi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-25-2012, 07:41 AM
  5. Replies: 4
    Last Post: 10-11-2010, 05:13 AM
  6. Random numbers to generate amount between two numbers
    By maverickbv80 in forum Excel General
    Replies: 2
    Last Post: 09-08-2010, 11:21 AM
  7. Macros to Generate text
    By danishm in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-05-2007, 07:47 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