+ Reply to Thread
Results 1 to 2 of 2

Help create unique data ranges for a monte carlo input

  1. #1
    Registered User
    Join Date
    06-04-2023
    Location
    Perth
    MS-Off Ver
    2016
    Posts
    1

    Help create unique data ranges for a monte carlo input

    Hi.

    I have 50 unique values and want to generate unique datasets from these 50 data point, but need to follow the following pattern/relationship that is best described by the following example.

    A to E represent the first 5 unique values of the 50 data points.

    Row 1-2 is generate from AB
    AB
    BA

    Row 3-6 is generated from row 1-2 by adding C to front and back
    ABC
    CAB
    CBA
    BAC

    Row 7-14 is generated from row 3-6 by adding D to the front and back of each row.
    ABCD
    DABC
    CABD
    DCAB
    CBAD
    DBAD
    BACD
    DBAC

    And so row 14-31 is generated from 7-14 by adding E to the front and back of each row.

    The potential exist to also go AB, ABC, CAB etc and invert these to generate BA, CBA and BAC.

    So AB will always be next to each other, C will always be next to any combination of AB, D will be next to any combination of ABC, E next to any combination of ABCD and so on. Is there a quicker way in excel to do this instead of doing it manually?

    Thank you.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: Help create unique data ranges for a monte carlo input

    You may use simple recursive macro which starts with
    1) one element in an array (A), and rest in string of letters to be processed then
    2) if the string to be processed is empty finishes activity, if not takes first letter of string to be processed, and
    3) adds it in front and in back of each element in an array, producing twice as long array as an original one
    4) writes this array into worksheet below earlier version (or could be overwriting previous one, if you don't need partial results)
    5) removes used letter from the string to be processed and
    6) returns to step 2 using this shorter string and array which has been created in step 3

    The limit is 21 elements, like ABCDEFGHIJKLMNOPQGRST in C1 (in case of only final results, because if partial results are needed too, then 20 elements), because
    because of filling whole column in excel sheet (1048576 rows). But even with such large number macro works almost instantenously.

    The code assuming all elements list is in cell C1 could look like this:

    Please Login or Register  to view this content.
    See how it works in attached file.

    And here is the version presenting only final results (full length)
    Please Login or Register  to view this content.
    Best Regards,

    Kaper

+ 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. Monte Carlo Data Table will not populate
    By PaulB48 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-10-2018, 09:02 PM
  2. Monte carlo using multipe data sources
    By kevinndocherty in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-15-2016, 03:13 PM
  3. Replies: 1
    Last Post: 06-04-2012, 05:25 PM
  4. Monte carlo
    By karan21 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-09-2011, 04:06 PM
  5. How can I create a monte carlo from a monte carlo?
    By rrbest in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-09-2010, 03:06 AM
  6. 2 Way Data Table issues when running monte carlo simulation
    By excel_nuance in forum Excel General
    Replies: 3
    Last Post: 03-04-2009, 12:28 PM
  7. How do I record Excel data from each Monte Carlo run?
    By LaStormPrep in forum Excel General
    Replies: 2
    Last Post: 05-08-2006, 06:55 PM

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