+ Reply to Thread
Results 1 to 11 of 11

How to get combinations and derive formulas?

  1. #1
    Registered User
    Join Date
    12-11-2014
    Location
    Germany
    MS-Off Ver
    2010
    Posts
    4

    How to get combinations and derive formulas?

    Dear all,

    I have a set of river discharge data from 19 dates, each containing two dependend values (water level (m) and water discharge (m³/s)). Simplyfied: A1, A2, B1, B2, ... S1, S2.
    I need to derive all rating curves for all combinations of three values. I want to do that using the LINEST function, where the x-values are defined by a three-value combination of the first variable (e.g. A1, B1, S1) and the y-values correspondandly (e.g. A2, B2, S2). Therefore I need all possible combinations from variable 1 and 2, giving me 2 x 969 combinations (n=19; r=3; no repitition; order doesn't matter).
    Unfortunately, the values are not fixed but normal distributed around each measured value for A - S. That means I generated random numbers (latin hyper cube) which are in an extra excel sheet, one column per measured value (A1, A2, B1, etc.). So, for the functions I want to use unique values.

    Is there a way to generate the 2 x 969 combinations automatically?
    Can excel also give me unique values from the random numbers sheet for each combination? (for example: A1i, B1i, C1i & A2i, B2i, C2i; next A1ii, B1ii, D1ii & A2ii, B2ii, D2ii. In the existing random number sheet the values (e.g. A1) are in columns with a large number of random numbers in rows beneath (i, ii, iii, ...).
    And would it be possible to arrange it in such a way that later I only need to pull down the LINEST function next to the combinations to obtain my 969 rating curve functions?

    I hope my issue is comprehensible, but I have to admit that it is fairly complex. At least it reaches far beyond my excel knowledge...
    Thanks for your help!

  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: How to get combinations and derive formulas?

    Hi grantor,

    Have a look on the attachment with simple (but probably effective enough for this purpose macro).

    Please Login or Register  to view this content.
    I followed your described input data layout. the output is 969 rows with linest for all combination of triplets of your data.
    I skipped in the macro the part about random sheets because I do not think I understood it well.
    Of course you can comment or delete out rows:
    Please Login or Register  to view this content.
    and use for instance INDIRECT function with RAND as input For instance see B10:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    and next cells in attachment (before running unmodified macro). And after macro - copy such INDIRECT formulas down. - you will introduce some stochastics into data picking process.

    Just for the future
    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    Attached Files Attached Files
    Last edited by Kaper; 12-16-2014 at 02:20 PM.
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    12-11-2014
    Location
    Germany
    MS-Off Ver
    2010
    Posts
    4

    Re: How to get combinations and derive formulas?

    Hi Kaper, thank you for your help! I've never worked with macros in excel before and was pretty fascinated by that simple script.
    However, I can't get it to do exactly what I need. I attatched a workbook for demonstration. It is important that in each combination the values are unique. Therefore I created a bunch of random numbers which are normally distributed around the measured values. I created them using an external program and copied them into the workbook. Each of these values (A1i, A1ii, ...) is supposed to be used only once in the combinations and I need to be able to replace them later on by copying in new values.

    Could anyone help me out with a macro that fills the columns of my 969 combinations with the unique random values? Or maybe share an idea how to approach this?

    All the best,
    grantor

    969 combinations and formulas.xlsx

  4. #4
    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: How to get combinations and derive formulas?

    Hi,
    I'm pretty sure I published answer yesterday morning. But can't see it now (the same happened in another thread: http://www.excelforum.com/excel-prog...ml#post3937239 ). Fortunately also your file was still in my trash. So try (again, it is not very quick - takes few seconds - but simple and easy to understand algorithm):
    Please Login or Register  to view this content.
    Last edited by Kaper; 12-23-2014 at 02:16 AM.

  5. #5
    Registered User
    Join Date
    12-11-2014
    Location
    Germany
    MS-Off Ver
    2010
    Posts
    4

    Re: How to get combinations and derive formulas?

    Hi,
    great work Kaper, thank you so much! It worked perfectly well with my 969 combinations.
    I'm now trying to understand and modify the macro but have some difficulties with that. Unfortunately this is my first time having to work with VBA. My goal is to be able to alter your macro to be able to crease the number of combinations (have only A - I data sets) and also change the number of random values: When there are fewer combinations, i = 153 should be decreased to the exact amount of unique numbers needed. With n=19 I end up with 969 combinations and i=153 unique values for each data set, with n=9 I have 84 combinations and i=28 unique values if I calculated correctly.
    I'd be very grateful if you or someone else could briefly outline how to adjust the macro.
    Happy New Year!

  6. #6
    Registered User
    Join Date
    12-11-2014
    Location
    Germany
    MS-Off Ver
    2010
    Posts
    4

    Re: How to get combinations and derive formulas?

    Kaper, I just found out that your macro works very well, even with fewer combinations! It tells me about some error while running the macro and wants me to debug line 10, but nevertheless it works. But why does it pick the random values from the second sheet ('LHC values') bottom up? Could that be changed?
    Again, thank you.

  7. #7
    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: How to get combinations and derive formulas?

    As the values are random, I thought, it does not matter what sequence they are picked.
    OK, Bottom-up is not-so-good, so what would be better - top-down:
    Please Login or Register  to view this content.
    of random row:
    Please Login or Register  to view this content.

    as for other numbers of combinations:
    5 (start row) To 973 (lastrow) is the scope for main loop - adjust it and make sure you provided enough data in LHC sheet.

  8. #8
    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: How to get combinations and derive formulas?

    PS. The number of rows you have to prepare in LH are "trianglular numbers" http://en.wikipedia.org/wiki/Triangular_number
    so for 3 dates just 1 LHC row, for 4-> 3, 9 -> indeed 28, 19-> 153, 26 -> 300 etc.

    and to prepare combinations sets (as used in sheet combinations) a bit modified piece of code from some posts above (run in empty sheet):
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    09-16-2016
    Location
    Brazil
    MS-Off Ver
    2016
    Posts
    5

    Re: How to get combinations and derive formulas?

    Hi there @Kaper.

    I want to the same thing as requested in the initial question but after obtain all possible sets of 6 numbers combination in the 60 number serie, I need to refine within all the set of 6 possible combinations, the sets that the sum of the six stay in the range of a minimum of 180 and a maximum of 191.

    It´s possible to get that with your code ?

    Thanks and cheers

  10. #10
    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: How to get combinations and derive formulas?

    Hi ocnerol,

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.

    So please do as advised above - post new thread and give a link to this one.

  11. #11
    Registered User
    Join Date
    09-16-2016
    Location
    Brazil
    MS-Off Ver
    2016
    Posts
    5

    Re: How to get combinations and derive formulas?

    Hi @Kaper

    I did what you said, here is my thread
    http://www.excelforum.com/excel-prog...mbination.html

+ 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. IF/THEN formulas with over 50 combinations
    By JCYoung in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-19-2013, 07:30 PM
  2. Finding possible combinations & listing the wanted combinations
    By Zoke in forum Excel Programming / VBA / Macros
    Replies: 30
    Last Post: 07-16-2012, 03:41 PM
  3. How to Derive Equations
    By jabronyo in forum Excel General
    Replies: 2
    Last Post: 04-16-2012, 10:17 PM
  4. Derive a value across 2 worksheets
    By JonUK01 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-26-2011, 07:31 PM
  5. Need to derive combinations for 4 elements each with 3 possible va
    By LAdekoya in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-08-2005, 08:30 AM

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