+ Reply to Thread
Results 1 to 5 of 5

Generate list based on product of variables

Hybrid View

  1. #1
    Registered User
    Join Date
    06-28-2020
    Location
    Riffa Views, Bahrain
    MS-Off Ver
    365
    Posts
    3

    Question Generate list based on product of variables

    Hi All,

    I'm working on mapping the process flows and estimating the expected activity durations at a manufacturing plant.

    I started by listing all the different product variations that would affect the routes and/or durations and came up with this (manually) for one group of products GGC Variations.PNG Variations List.PNG

    Now I need to create another list for a different group of products, that have a total of 6912 variations. See attached BV Variations.PNG

    I don't have any experience with vba but I figured there must be an easier solution than listing each variation manually. Can someone help me out with this please?
    Attached Files Attached Files
    Last edited by kareem92; 02-16-2022 at 07:20 AM. Reason: Solved

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,322

    Re: Generate list based on product of variables

    Welcome to the forum.

    There are instructions at the top of the page explaining how to attach your sample workbook.

    A good sample workbook has just 10-20 rows of representative data that has been desensitised. It also has expected results mocked up, relevant cells highlighted and a few explanatory notes.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,706

    Re: Generate list based on product of variables

    code wise, you could use something like:

    Public Sub Standard()
    
        Dim avVariation, avInfo, vTmp, vTmpP, avOut
        Dim lngR As Long, lngC As Long
        avVariation = Sheets("Setup").Range("A2:J10")
        ReDim avInfo(1 To 2, 1 To UBound(avVariation, 2))
        vTmpP = 1
        For lngC = LBound(avVariation, 2) To UBound(avVariation, 2) Step 1
            vTmp = 0
            For lngR = LBound(avVariation, 1) To UBound(avVariation, 1) Step 1
                vTmp = vTmp - (avVariation(lngR, lngC) <> "")
            Next lngR
            avInfo(1, lngC) = vTmp
            avInfo(2, lngC) = vTmp * vTmpP
            vTmpP = avInfo(2, lngC)
        Next lngC
        ReDim avOut(1 To vTmpP, 1 To UBound(avVariation, 2))
        For lngR = LBound(avOut, 1) To UBound(avOut, 1)
            For lngC = LBound(avOut, 2) To UBound(avOut, 2)
                avOut(lngR, lngC) = avVariation(1 + Int(lngR / (vTmpP / avInfo(2, lngC))) Mod avInfo(1, lngC), lngC)
            Next lngC
        Next lngR
        With Sheets.Add
            .Name = "Variations_" & Format(Now, "yyyymmddhhmmss")
            .Cells(1).Resize(UBound(avOut, 1), UBound(avOut, 2)).Value = avOut
        End With
    
    End Sub
    but, if interested, you could achieve the same thing using formulae -- let us know.
    note: above is one method - there will be plenty of others (some no doubt more efficient than the above) -- but this code would generate your 6912 combos in a second or so.

  4. #4
    Registered User
    Join Date
    06-28-2020
    Location
    Riffa Views, Bahrain
    MS-Off Ver
    365
    Posts
    3

    Re: Generate list based on product of variables

    Thank you! Let me try it out now. I kept looking into yesterday and eventually ended up downloading an excel add on that sorted it out for me.

  5. #5
    Registered User
    Join Date
    06-28-2020
    Location
    Riffa Views, Bahrain
    MS-Off Ver
    365
    Posts
    3

    Re: Generate list based on product of variables

    - Found this solution on extendoffice 5891 excel all combinations of 3 columns. Hope this helps!

+ 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: 1
    Last Post: 05-12-2016, 09:29 AM
  2. [SOLVED] VBA to to create a list of product variations based on list of parent products
    By irruzzz in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-12-2016, 08:27 AM
  3. Generate a numerical sku based on product number
    By timmay9162 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-16-2015, 11:18 PM
  4. Generate Product Pick List and transfer to Existing Workbook
    By aaron.meza in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-01-2011, 03:38 PM
  5. Generate List based on specific Variables being Met
    By swankrain in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-04-2010, 04:55 PM
  6. Transfer Data to separate tables based two variables (site and product)
    By yunesm in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-15-2010, 09:47 PM

Tags for this Thread

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