+ Reply to Thread
Results 1 to 89 of 89

Combination of two iterative formula

  1. #1
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Combination of two iterative formula

    Hi all,

    Been having some problems with getting the results I want from the iterations.
    So I have some names in Array 1 which correspond to a given number, and Cell M7:M11 will display the first name that doesn't appear within Array 2.
    In Cells M14:17 I have a formula which then looks to see whether the name in cells M8:11 has already been used, and if so, to move to the next name on the list.
    This is where I've hit the speed bump. I have been able to have it move along one column, but without manually typing out the iteration, can't get it to move any further.
    Any help would be greatly appreciated.

    Thanks,

    Max

    EDIT: Removed VBA from file, hoping should remove any issues.
    Attached Files Attached Files
    Last edited by Valont; 04-27-2020 at 07:55 AM.

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

    Re: Combination of two iterative formula

    Max, not sure about others but for me the file is reporting corrupted status which, given .xlsm extension, makes people a little wary.

    Can you post another sample, devoid of VBA - i.e. either .xlsb or .xlsx

  3. #3
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    Have updated, thanks for the heads up

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,728

    Re: Combination of two iterative formula

    Have you asked this question on any other forums? (e.g. Reddit)

    If so, please follow the forum rule on cross-posting: https://www.excelforum.com/forum-rul...rum-rules.html
    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.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    I have posted on reddit, tried to update but am not allowed to post links.
    Last edited by AliGW; 04-27-2020 at 04:34 PM.

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

    Re: Combination of two iterative formula

    Hi, not sure if I fully understand but it seems your precedence logic is relatively convoluted.

    If you can add a key, of sorts, it will help - I think...

    Using your sample file:

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    the results can then leverage the above, e.g.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    if the above isn't what you meant, or you cannot use a key (as outlined) post back ... but... if the logic is as complex as your desired results imply then this may get a bit convoluted.

    edit: added attachment to illustrate above -- my results in M (i.e. adjacent to your expected results)... if you add to array 2 the results stay in sync, so I think it apes your logic (just not sure how useful)
    Attached Files Attached Files
    Last edited by XLent; 04-27-2020 at 10:38 AM.

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

    Re: Combination of two iterative formula

    Sorry Valont, that doesn't work !
    i.e. Stephen repeats, 6th instance, and should not, so it's missing an extra check.

    Will revisit, apologies for confusion.

  8. #8
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    Quote Originally Posted by XLent View Post
    Sorry Valont, that doesn't work !
    i.e. Stephen repeats, 6th instance, and should not, so it's missing an extra check.

    Will revisit, apologies for confusion.
    Hopefully a little extra info will help here, because it seems to be working as expected as far as I can tell.

    Array 1 is a list of available employees, that can be assigned to jobs 1 through 5 (but only ones they have been trained in).
    Array 2 is a list of unavailable employees (off sick/holiday).

    The general idea is that it will choose the first name from the list, but if they're unavailable, choose the next person, without assigning two jobs to one employee.
    So it won't have to go any further than the 5 jobs (in this case) and any unused staff will populate a spare section later.

    I hope that clears it up a little?

    The actual data is just a longer list in both directions, so more employees and more jobs, but the concept is the same.
    (I would share the actual workbook but for GDPR reasons sadly I can't)

    Appreciate your help a lot!

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

    Re: Combination of two iterative formula

    so, in my file you will see Stephen listed twice (rows 15 & 18), so whilst top 5 is ok things go awry thereafter

    reason for the above is the key - given this is looking above (only) and not below and left... so key in U8 should be 0, but isn't.

    questions for you

    1. if Craig were added to Array 2 what would your expected outcome be

    2. just to confirm, order of precedence is: pick first valid person per row then, having iterated all rows, pick 2nd valid person per row if available etc...

    question 2 is key - if you don't care about the precedence so much, i.e. just want 5 unique people, it's a lot (lot) simpler.
    Last edited by XLent; 04-27-2020 at 11:03 AM.

  10. #10
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    Quote Originally Posted by XLent View Post

    1. if Craig were added to Array 2 what would your expected outcome be

    2. just to confirm, order of precedence is: pick first valid person per row then, having iterated all rows, pick 2nd valid person per row if available etc...

    question 2 is key - if you don't care about the precedence so much, i.e. just want 5 unique people, it's a lot (lot) simpler.
    1. JOHN, TREVOR, STEPHEN, THOMAS, JOANNE
    2. The only precedence is to keep the first name on that job unless unavailable or absolutely necessary to move them. So, choose from column C, if can't, choose any of remaining names

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

    Re: Combination of two iterative formula

    Hi, would "approach2" work for you?

    In this approach M7:R11 do a lot of the legwork to return / prioritise names as they should be utilised.

    For sake of illustration I opted to add both Craig & Thomas to the 2nd Array such that row 4 holds no valid results.

    On big data sets this may not prove particularly efficient...
    Attached Files Attached Files

  12. #12
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    Hi,

    Not sure I've fully understood, but perhaps this array formula** in N13:

    =IFERROR(INDIRECT(TEXT(MMULT(10^{5,0},0+MID(TEXT(MIN(IF(C$2:I$6<>"",IF(COUNTIF(C$11:C$16,C$2:I$6)=0,IF(COUNTIF(N$12:N12,C$2:I$6)=0,10^5*COLUMN(C$2:I$6)+ROW(C$2:I$6))))),"R00000C00000"),{8;2},5)),"R00000C00000"),0),"")

    https://excelxor.com/2014/08/22/adva...nd-discussion/

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  13. #13
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    Quote Originally Posted by XLent View Post
    Hi, would "approach2" work for you?
    Unfortunately not, in the instance that no other names would be available, the wanted response would be to move Trevor onto that job, but as Joanne hasn't been trained in job 4, there's no instance in which she can be assigned to it.
    I'm now realising how difficult this is, I'm relatively new to using excel to more than a simple sum, so I appreciate the help!
    If the above is too much, is it possible to have it left blank?


    Quote Originally Posted by XOR LX View Post
    Hi,

    Not sure I've fully understood, but perhaps this array formula** in N13
    Afraid not, as mentioned above, the names have to be applied to specific jobs, and can't be moved around freely.

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

    Re: Combination of two iterative formula

    Quote Originally Posted by Valont View Post
    Unfortunately not, in the instance that no other names would be available, the wanted response would be to move Trevor onto that job, but as Joanne hasn't been trained in job 4, there's no instance in which she can be assigned to it.
    OK. But, in above scenario (with both Craig & Thomas in Array 2) could you assign Trevor to Job 4 given fact Trevor is first to be assigned to Job 2 ?

    The reason I ask is that because if you need to somehow determine the "optimal mix" I'm not sure this is feasible.

    To elaborate; with those names in Array 2 you may decide that the 'optimal' approach would be to assign Fred, rather than Trevor, to Job 2 such that Trevor can do Job 4 which would otherwise be empty, the only other Job Fred is trained on is Job 5 and Joanne would be 'first cab off the rank' for that.

    If you take it a step further and then add Joanne to Array 2 it gets a whole lot more complicated again as Fred would now be first choice for Job 5 etc...

    If, conversely, you wish only to identify the first valid person for each job, mindful of those who may have already been assigned to other "earlier" jobs, then:

    N13:
    =IFERROR(INDEX($C2:$I2,MATCH(1,INDEX(($C2:$I2<>"")*ISNA(MATCH($C2:$I2,$C$11:$C$16,0))*ISNA(MATCH($C2:$I2,N$12:N12,0)),0),0)),"")
    copied down to N17 (i.e. Jobs 1-5)

    but, seems over simplified ?

    edit: and thanks XOR LX ... nice!
    Last edited by XLent; 04-28-2020 at 03:53 AM.

  15. #15
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    You could assign Trevor to job 4 despite being first option for job 2, yes, but only in the instance that Trevor is the only name left (as he is here).

    Small but potentially important clarification, Fred isn't necessarily the first choice for job 5 if Joanne is unavailable. Just happens to be the way the names are ordered, but any of the names following those in column C have the same preference as each other. If that makes sense?

    Does appear as though the 'optimal mix' as you say is a lot more complicated when analysed than when I first thought.
    The only potential saving grace is that the real data includes over 100 names, and in almost all cases, there's around 5 staff trained in each route at a minimum.
    Although another issue is that they're all listed alphabetically backwards, so the name in column D is often the same.

    As expected the next formula doesn't quite work. There's no duplicates but some names are being removed despite not being in array 2.

  16. #16
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    It would seem to me that things would be far more straightforward given a re-uploaded workbook with several permutations of names/exclusions together with expected results. As it stands, there are a dozen or so posts going back and forth in an attempt to establish the logic for various scenarios.

    Regards

  17. #17
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    Hadn't thought of that!
    Can you tell I'm new to this?
    Hopefully this will help a little?
    Attached Files Attached Files

  18. #18
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    Thanks a lot. Now I understand!

    Will take a look.

    Regards

  19. #19
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Combination of two iterative formula

    I need helper column

    B11
    =INDEX(C$11:C$15,MATCH(ROWS(B$11:B11),MOD(SMALL(($A$2:$A$6-MMULT(COUNTIF(A$11:A$15,$C$2:$I$6),{1;1;1;1;1;1;1}))*100+$B$2:$B$6,$B$2:$B$6),100),))

    C11 helper
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  20. #20
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    This extra column brings back the right names but not in the correct place unfortunately
    Last edited by AliGW; 04-28-2020 at 09:24 AM. Reason: Please don't quote unnecessarily!

  21. #21
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Combination of two iterative formula

    That's why I call it helper column.

    And then use the formula in B11 to get the name in correct place.

  22. #22
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    Oh it goes right to left, I'm with you, my mistake!
    That's interesting ok.
    Let me see if I can get that to work!
    Last edited by AliGW; 04-28-2020 at 09:23 AM. Reason: Please don't quote unnecessarily!

  23. #23
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    Just tested it a little and have an undesirable response come back.
    I added Craig to the first list and it changed Trevor.
    Have updated my original expected book, attached here, to show the desired response.
    Attached Files Attached Files
    Last edited by AliGW; 04-28-2020 at 09:23 AM. Reason: Please don't quote unnecessarily!

  24. #24
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    Re your expected results, can you just clarify why you can't have Trevor as second pick in your 3rd and 4th examples (i.e. cells H12 and K12)?

    Regards

  25. #25
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    Trevor isn't an appropriate response in H12 and K12 because he has to be in H14 and K14, as both of the other employees are unavailable for job 4, and he is the only name left. Therefore it's ok to move him from his normal job so job 4 isn't left unassigned.
    However, he can stay in E12 because there is another staff member available for job 4 (E14) in the second example.
    Hope that clears things up a little?
    Last edited by AliGW; 04-28-2020 at 09:22 AM. Reason: Please don't quote unnecessarily!

  26. #26
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Combination of two iterative formula

    Please try again

    B11
    =INDEX(C$11:C$15,MATCH(ROWS(B$11:B11),MOD(SMALL((TEXT($A$2:$A$6-MMULT(COUNTIF(A$11:A$15,$C$2:$I$6),{1;1;1;1;1;1;1}),"[>1]"&$B$2:$B$6&";\0"))*100+$B$2:$B$6,$B$2:$B$6),100),))

    C11 Helper column
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  27. #27
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    So that's sorted almost all of the results I can think of, which is great, but is inconsistent.
    If you put just John's name in the exceptions, Stephen moves from job 3 (when he shouldn't).
    Whereas when you do the same for Craig, it leaves Trevor and chooses Thomas as desired.

    Hoping that makes sense.
    And moreso, hoping you guys don't think I'm being difficult for the sake of it.
    Have to expand the formula to about 150 employees and 120 jobs, and I'm past the point of being able to reverse engineer what you guys are throwing at me.
    Just want to reiterate how grateful I am for trying to help me out here!

  28. #28
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    Quote Originally Posted by valont View Post
    If you put just john's name in the exceptions, stephen moves from job 3 (when he shouldn't)
    Re the above, if Stephen is to stay in Job 3, that forces Joanne to go into Job 1, no? Which means that she has been forced out of Job 5. Is that preferable to Stephen being moved and, if so, why?

    Apologies if I'm not fully grasping the logic here.

    Regards

  29. #29
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    Also, I just went back to check your original file to see if there was anything I'd missed. And then I noticed the TEXTJOIN function in there.

    Your profile says Excel 2010, yet TEXTJOIN is an Office 365/Excel 2019 function. Can you clarify? This could make a potentially significant difference to proposed solutions.

    Regards

  30. #30
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    Been staring at this sheet for so long I did miss that it would have to pick between Stephen and Joanne, so well pointed out!
    That being said, if you add a fourth name into the first job, and only John into exceptions, it still moves Stephen into job 1.

  31. #31
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    Regarding Textjoin, we tried to give it a go, and used a UDF to get it working, but still hadn't managed to get the results we wanted.

  32. #32
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    So this has to work for 2010?

    Regards

  33. #33
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    It does yes, but can apply a UDF to a workbook if it can be saved with it.
    I believe I said that in my original post, but if not I've wasted a lot of your time :/

  34. #34
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    Any luck today?
    We're looking into changing the requirements as it looks like it's potentially a little too much to ask. Would it be significantly easier if we made it so that the main drivers never move? So for example, if John were unavailable, it would come back with a 0 and leave both Stephen and Joanne in their 'preferred' jobs?

  35. #35
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    Still looking into the original problem. Hopefully have something back for you this evening.

    Regards

  36. #36
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Combination of two iterative formula

    Maybe try this

    B11 DESIRED
    =INDEX(C$11:C$15,MATCH(ROWS(B$11:B11),MOD(SMALL(FIND(1,MMULT(1-(COUNTIF(A$11:A$15,$C$2:$I$6)),TRANSPOSE(10^-COLUMN($C$2:$I$6))))*1000+$B$2:$B$6,$B$2:$B$6),1000),))

    C11 helper
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  37. #37
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    Is this for the restructured idea without the main drivers moving?
    Had a little play but it seems to skip some other names where it shouldn't.
    For example, I put Joanne, Trevor and Thomas in exceptions, which should move Fred up to job 2 as there are others available for job 5, but it doesn't.

  38. #38
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    Hi,

    I believe I'm close to a final solution. However, would it be possible to have perhaps half a dozen or so more scenarios with expected results for testing? As varied and comprehensive as you can, if you could.

    I'm referring to the original problem.

    Regards

  39. #39
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    Hopefully this will give you a decent number of examples!
    Attached Files Attached Files

  40. #40
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    Thanks, but unfortunately that seems to contain identical examples to those in the workbook you supplied in post #23.

    Regards

  41. #41
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    There should be another row of them below the first one, so 12 in total?

    EDIT: Uploaded the wrong file, here it is.
    Attached Files Attached Files

  42. #42
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    Array formula** in B11:

    =IF(SUM(N((C2:I2<>"")-COUNTIF(A$11:A$15,C2:I2)=1))=1,T(INDEX(C2:I2,MATCH(1,(COUNTIF(B$10:B10,C2:I2)=0)*(COUNTIF(A$11:A$15,C2:I2)=0),0))),LOOKUP("Ω",T(INDEX(C2:I2,N(IF(1,MATCH({1,9},8*(C2:I2<>"")*(COUNTIFS(C$2:C$6,C2:I2,C$2:C$6,"<>"&C2)=0)+(COUNTIF(B$10:B10,C2:I2)=0)*(COUNTIF(A$11:A$15,C2:I2)=0)*(ISNA(MATCH(C2:I2,T(INDIRECT(TEXT(MODE.MULT(IF(IF(MMULT((C$2:I$6<>"")-COUNTIF(A$11:A$15,C$2:I$6),TRANSPOSE(COLUMN(C$2:I$6)^0))=1,COUNTIF(A$11:A$15,C$2:I$6))=0,10^5*ROW(C$2:I$6)+COLUMN(C$2:I$6)),10^5*ROW(C$2:I$6)+COLUMN(C$2:I$6)),"R0C00000"),0)),0))),0)))))))

    and copied down as required.

    Any blank cells within ARRAY 1 must be 'genuinely' empty, i.e. not contain the null string (""), e.g. as a result of formulas in those cells. With some additional work, I could amend it so that it works in those cases as well, if required, though I presumed that these were manually-entered values and so null strings would not be present.

    Of the examples in your last file, my results concur with yours for all apart from those in D19:E23, for which JOANNE appears twice in ARRAY2, and those in M19:N23, though due perhaps only to a difference in preference: you move JOANNE and keep STEPHEN, I move STEPHEN and keep JOANNE.

    Regards


    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).

  43. #43
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    In the actual dataset, the blank cells are formula results, in order to be able to add staff to the matrix as they do further training, save adding them all individually. So if that change isn't too tough that would be ideal.
    As you say M19:N23 is just a preference in the way that I wrote the response, but either would be fine

    I think I have one of the expected results wrong :'(
    The only one in lower case, not sure what happened with it.
    H11:15 should read either
    Stephen, John, Andrew, Trevor, Joanne
    OR
    Joanne, John, Stephen, Trevor, Tony
    Dependent on preference, similar to M19:N23 as you mentioned.

    I'm sorry I missed that. Works a treat otherwise! Not that that is much of a consolation at this point.

  44. #44
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    Quote Originally Posted by Valont View Post
    H11:15 should read either
    Stephen, John, Andrew, Trevor, Joanne
    OR
    Joanne, John, Stephen, Trevor, Tony
    Can you clarify why these are preferable to the output I generate of John, Fred, Stephen, Trevor, Joanne? All 3 options retain 4 of the 5 original entries in the first column.

    Regards

  45. #45
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    Which file are you using? Does G:11:15 match J19:23?
    In the one I have now, G11:15 contained Craig, Thomas and Fred.
    Which should return either of the above, but doesn't.
    This is the only result that hasn't come back correct from any that I have tried.

  46. #46
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    Ok, thanks. Back to the drawing board on that one...

  47. #47
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    Hi,

    Unfortunately your last example has made me aware of the full scope of the problem you are hoping to solve, and I do not believe that it is solvable using Excel formulas alone. Perhaps something could be achieved with VBA, looping through various scenarios and assigning an 'optimised' score to each until the necessary conditions are met.

    And that - a problem in optimisation - is what I realised you're facing here after looking at the counter-example you gave in your last message. It's also what XLent seemed to grasp way before I did, to his/her credit.

    The only way this can be feasibly approached using Excel formulas alone is to build a set of hierarchical logic steps to follow. Which is what myself and the other two posters have attempted. However, without some form of iteration (of which VBA looping could be considered an example), scenarios such as your last are virtually impossible to resolve: in order to know that John cannot be picked for the first row, we must see that Trevor is the only pick for the fourth row, which implies that John is the only possible pick for the the second row...

    And this 'three-level' case is, I imagine, only a relatively simple example of the recursive logic inherent here. As the size of the dataset increases, I would imagine the number of permutations necessary to examine becoming exponentially large.

    I have worked on optimisation problems in the past, sometimes thrashing them out in the worksheet initially, then moving onto VBA, before finally realising that Excel is just not the right tool. I hope I'm wrong in this case - it might be worth re-posting in the VBA section of the forum to see if anyone takes it up there. In any case, best of luck with it!

    Regards

  48. #48
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    I really appreciate all your help, I could never have imagined it get this complicated for my first excel project, but I can't thank you enough for the time you've put into it!
    Looks like we will have to rethink the desired outcome, potentially just have it look along the list and never move any of the first drivers, return 0 or error if no other drivers are available. Put in some manual work, can't do much harm.
    If that sounds easy enough, let me know, but I can understand if you've seen enough of it!

    Once again, thank you for all the time you've put in. If I could buy you a beer, I would! <3

  49. #49
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    So is VBA something you'd consider? Would be happy to try to write some code myself if that's a route you'd like to go down.

    Ah, English beer! Now that is one thing I definitely miss!

  50. #50
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    Absolutely, assuming it works in the same way as a UDF and you can save it with the workbook, would be interested to see it yeah.
    Want to learn as much as I can so worth giving it a go

    Although I think we might be going down the more manual route seeing how complicated it is. So as I said above, where we move along a row and only change around the names after the main driver.
    I'll upload another sheet with some examples below for the simple sheet.

    And yet all of the Brits want foreign beer!

  51. #51
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    Quote Originally Posted by Valont View Post
    I'll upload another sheet with some examples below for the simple sheet.
    Ok, I'll wait for that and see if it looks solvable using worksheet formulas alone. If not, we'll look at some VBA.

    Quote Originally Posted by Valont View Post
    And yet all of the Brits want foreign beer!
    Indeed!

  52. #52
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    Hopefully this will be nice and simple!
    Attached Files Attached Files

  53. #53
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    Quote Originally Posted by Valont View Post
    Hopefully this will be nice and simple!
    Perhaps, but re:

    Quote Originally Posted by Valont View Post
    Would it be significantly easier if we made it so that the main drivers never move? So for example, if John were unavailable, it would come back with a 0 and leave both Stephen and Joanne in their 'preferred' jobs?
    can you clarify your expected results in the new file?

    Who are the "main drivers"?

    Why, in your examples, do John and Craig return blanks in your 1st and 3rd examples respectively, but Trevor (in the 2nd and 4th examples) and Craig (in the 4th example) do not?

    And why are the expected results for the 5th example all blank?

    Regards

  54. #54
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    So main drivers would be the first names in the list, so in Array 1, those in column C.

    In the 1st, when John is unavailable the replacements are both main drivers, so wouldn't swap around.
    In the 3rd, similar concept, Craig and Thomas leave only Trevor for route 4, but as he is the main driver on route 2, doesn't move.

    I hope that makes sense with the main driver concept?

    And 5th example I just didn't finish, I was doing other work and just missed it completely. Whoops!
    It should return: John, Trevor, "Blank", Craig, Joanne.

    Thanks

  55. #55
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    Thanks. Understood.

    Need at least a dozen more scenarios for testing purposes, if you could.

    Many thanks.

  56. #56
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    For example, what would you now expect the result to be for the previously problematic ARRAY 2 of Craig, Thomas, Fred?

    Regards

  57. #57
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    Hopefully this is enough examples
    Attached Files Attached Files

  58. #58
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    Thanks a lot. Can you just double-check your expected results for 2 of those scenarios, i.e.

    JOHN
    CRAIG
    JOANNE

    and

    STEPHEN
    JOANNE
    FRED


    For the former I don't understand why you have ANDREW in the 3rd row and not STEPHEN. For the latter I don't understand why you have FRED in the 2nd row and not TREVOR.

    Regards

  59. #59
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    The former, as you say, should be Stephen, and not Andrew.
    The latter is also as you say. Clearly my mind turned to mulch as I tried to get these to you.
    Good spot!

  60. #60
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    Hi,

    Unfortunately, this change does nothing to resolve the issue which caused my previous solution to fail, i.e. we can always construct scenarios such as this:

    ARRAY 1
    JOHN CRAIG
    JABRONY ANDREW THOMAS TONY JIM TREVOR STEPHEN
    FRED THOMAS JIM JOHN
    STEPHEN
    CRAIG ANDREW

    ARRAY 2
    THOMAS
    JABRONY
    TONY
    FRED
    CRAIG

    Here the best I can achieve is:

    JOHN
    JIM

    STEPHEN
    ANDREW


    though of course you would expect:

    JOHN
    TREVOR
    JIM
    STEPHEN
    ANDREW


    Will have an initial look at some possible VBA set-ups.

    Regards

  61. #61
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    Well that's not how I saw that turning out, appreciate you trying
    Look forward to seeing how VBA turns out.

  62. #62
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    Had a quick thought.
    Were you trying to make the 'simple' formula for the whole array?
    I currently have a formula where it looks through the exceptions and moves along the list until it finds a unique name, which works great.
    I just need to combine that with a formula that checks that one cell for a conflict within the assigned jobs list. Which I can apply to each row separately.

    Would that change anything?

    Ta

  63. #63
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    Sorry, not sure what you mean. Can you clarify with reference to the example I posted?

    Let me reiterate the issue with that example as I see it with respect to any formula-based approach:

    ARRAY 1
    JOHN CRAIG
    JABRONY ANDREW THOMAS TONY JIM TREVOR STEPHEN
    FRED THOMAS JIM JOHN
    STEPHEN
    CRAIG ANDREW

    ARRAY 2
    THOMAS
    JABRONY
    TONY
    FRED
    CRAIG

    Row 1 is obvious, so let's move to row 2:

    JABRONY cannot be picked. (He's in ARRAY2)
    ANDREW cannot be picked. (Only choice for row 5, since CRAIG is in ARRAY2)
    THOMAS cannot be picked. (He's in ARRAY2)
    TONY cannot be picked. (He's in ARRAY2)

    which seemingly leads to JIM being a valid choice: he's not in ARRAY2, he doesn't occupy one of the current 'leader' positions, and he wasn't our choice for row 1.

    However, as we have seen, this leads to row 3 being blank.

    The problem is that, if only we had the foresight (in technical terms, if we were to see what the results in following rows would be if JIM were chosen), we might reject him in favour of TREVOR or STEPHEN.

    But this then leads to the conclusion that the only feasible approach would be to analyse all permutations of people for any rows which are not immediately resolvable, and seeing which of those permutations satisfies the criteria.

    How, for example, would your own formula-based approach seek to reconcile this problematic case?

    Regards
    Last edited by XOR LX; 05-04-2020 at 12:42 PM.

  64. #64
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    The foresight would be great yes, and in this specific case there would be a lot of blank responses.
    We're looking for a more temporary response alongside the complete work around (that VBA might be able to give us).

    Within a matrix of over 100 drivers, there would be few cases where several of the jobs would be unfilled, as we're commonly looking at less than 10 that are unavailable.
    But in that event, we would still have someone manually look up the available drivers and make the necessary change when things came back blank.

    So it's more that we were hoping it would be a potential middle step so that we could see how it would work with a decent amount of manual input, because it's more than likely that there would be only a handful of cases each day.

    I hope that follows some kind of logic?
    If not, I'll try again.

  65. #65
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    If I've understood you correctly, you're saying that the solution I've devised which generates the output for the case we've been discussing, although sub-optimal, would be of use to you right now, at least whilst I look into potentially superior VBA set-ups?

    If so, happy to give you that solution. If not, apologies if I've misunderstood.

    Regards

  66. #66
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    If you can fire it over I can see how far it gets me, there's no harm in trying

  67. #67
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    This version also works with null strings ("") in ARRAY 1. In B11, array formula**:

    =IF(SUM(N((C2:I2<>"")-COUNTIF(A$11:A$15,C2:I2)=1))=1,IFERROR(T(INDEX(C2:I2,MATCH(1,(COUNTIFS(C$2:C$6,C2:I2,C$2:C$6,"<>"&C2)=0)*(COUNTIF(B$10:B10,C2:I2)=0)*IF(C2:I2<>"",COUNTIF(A$11:A$15,C2:I2)=0,1),0))),""),IFERROR(T(INDEX(C2:I2,MATCH(1,(COUNTIFS(C$2:C$6,C2:I2,C$2:C$6,"<>"&C2)=0)*(COUNTIF(B$10:B10,C2:I2)=0)*IF(C2:I2<>"",COUNTIF(A$11:A$15,C2:I2)=0,1)*(ISNA(MATCH(C2:I2,T(INDIRECT(TEXT(MODE.MULT(IF(COUNTIF(C$2:C$6,C$2:I$6)=0,IF(IF(MMULT((C$2:I$6<>"")-IF(C$2:I$6<>"",COUNTIF(A$11:A$15,C$2:I$6),0),TRANSPOSE(COLUMN(C$2:I$6)^0))=1,IF(C$2:I$6<>"",COUNTIF(A$11:A$15,C$2:I$6),0))=0,10^5*ROW(C$2:I$6)+COLUMN(C$2:I$6))),10^5*ROW(C$2:I$6)+COLUMN(C$2:I$6)),"R0C00000"),0)),0))),0))),""))

    Regards

  68. #68
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    So I'm having trouble getting the formula to work within the actual workbook.
    I'm assuming the problem is working across sheets within the same workbook? Either that or that I'm using named arrays instead of C$3:AA$3 for example.
    Don't suppose you would have any ideas as to why this is the case?

  69. #69
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    Quote Originally Posted by Valont View Post
    So I'm having trouble getting the formula to work within the actual workbook.
    In what sense is it not working? Errors? If so, what type? Or just unexpected results?

    Have you remembered to commit it as an array formula**?

    Quote Originally Posted by Valont View Post
    I'm assuming the problem is working across sheets within the same workbook?
    Sorry, what precisely do you mean by this?

    Quote Originally Posted by Valont View Post
    Either that or that I'm using named arrays instead of C$3:AA$3 for example.
    No, that's a perfectly good idea.

    Regards

    P.S. VBA's coming along, if slowly. Will let you know as soon as I have something finalised.

  70. #70
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    So all responses are coming back empty. Whether that is blank "" or anything else. But not coming back as an error.
    Have been entering it as an array formula with Ctrl+Shift+Enter, but still no luck.

    So the formula you gave is going in one sheet, but looking up information from other sheets within the same workbook.
    Most of the ranges I have set up as named arrays, but without creating and naming 120 different arrays for each route, I have gone for referencing it by cell range.
    So in this case, it is as follows:
    KNOWLEDGE!C$3:AA$3
    Where in your formula we have C2:I2.

    HOLD UP!
    Think I've cracked it myself, watch this space.

    Otherwise, everything lines up with the new data as desired, and still getting an empty response.

  71. #71
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    Have you resolved the issue?

    Regards

  72. #72
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    Sorry I didn't get back to you yesterday.
    Sadly not, I managed to get the first name back in some cases, but when adding names to the exceptions, nothing changes.
    Will have a look around today, see if I can work something out.

    EDIT
    Have now updated the cells to match (small mistake on my part) and it has stopped bringing back names altogether. Just bringing back 0's now.
    Head-scratcher for sure.
    Last edited by Valont; 05-07-2020 at 03:48 AM.

  73. #73
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    Perhaps if you attach a small, dummy workbook which illustrates the issue you're having I'll be able to help.

    Regards

  74. #74
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    Yeah I'm trying to think of how I can make that work too.
    I'll see what I can do and get back to you.

  75. #75
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742
    FYI VBA going well, if slowly. Should have something for you this weekend.

    Regards

  76. #76
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    What size are ARRAY1 and ARRAY2 in actuality?

    Regards

  77. #77
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    Missed the notification over the weekend, apologies fro the delay.

    There are 140 names and 120 different jobs.
    There are groups of jobs in which names are usually grouped, so in most cases, each worker knows around 6 jobs, with a number of exceptions.
    So while we are dealing with larger numbers, each group is almost its own table, with some crossover.

    I hope that makes sense?

  78. #78
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    Ok, I think the full set-up might present too many permutations for Excel to handle. If the reduced, group-based version is an option for you, please clarify an upper limit on the dimensions (rows and columns) per group for ARRAY1 and ARRAY2. Any crossover would have to be handled separately.

    Regards

  79. #79
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    I'm not really sure the grouping idea would work.
    They're roughly grouped, but it's not concrete by any stretch so coming up with different formula for the different groups would cause more issues because of the crossover, I think.
    Especially with the way that the names are listed, as it would create too many duplicates.

  80. #80
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    Ok, now working on Plan C: a hybrid formula/VBA set-up.

    Regards

  81. #81
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    Once again, can't thank you enough for continuing to look into this all for me!

  82. #82
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    Quote Originally Posted by Valont View Post
    There are 140 names and 120 different jobs.
    Can you just clarify the above? ARRAY1 in your original examples was 5 names and 7 jobs. Are you saying that the range to consider now has to extend across up to 120 columns? Or is a given person never allocated more than a set number of jobs?

    If it must be up to 120 columns, how did you get along with implementing my formula? I would imagine that one instance of the formula I provided would take quite a long time to calculate over a 120x140 range (i.e. 16,800 cells), never mind 140 instances of that formula.

    Still, it would get there in the end, I believe. I just want to understand that these dimensions are correct before I start testing over such ranges myself.

    Regards

  83. #83
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    The highest number of names on a given job is 23, but in most cases it's not more than 10.
    Could cut the 23 down to around 15 if that would make a big difference too, although the concept of being able to future proof for new trainees would be invaluable.
    There are 140 different names contained within the array, but not on each route, so hopefully only looking at around 2500 cells.
    All that being said, it wasn't that it took a while to come back with 0, it was almost instant. I couldn't work out why it didn't work, and I only applied it to 5 cells when initially testing it.

    Hopefully that's useful!

  84. #84
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    Apologies. I've tried everything I can, though I can't generate a solution which will guarantee correct results for a dataset of the dimensions you have.

    I have managed to create a VBA set-up which always works, yet only for datasets significantly smaller than that which you have. The hybrid formula/VBA set-up led to some interesting attempts, though in the end the stumbling block for all solutions I've thus far attempted is that, despite there being several criteria in place which help to reduce the required computations, with a dataset in the region of 140x120, you are always left with an astronomical number of permutations to calculate (for example, even assuming fully one half of the 140 rows can be disregarded by virtue of the known criteria, for the remaining 70 rows, if on average just 2 of the people are eligible choices for each of those rows, that still necessitates computing 2^70 (one sextillion!) permutations in order to guarantee success.

    Of course, the original formula set-up I gave you will work fine over such large ranges, but then that set-up is not looking at all permutations and, as such, although it may well offer an 80% success rate (or even higher, perhaps), it can never be guaranteed to produce 100% correct results.

    I hope that you have better luck than I have and all the best with a very interesting project!

    Regards

  85. #85
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    Once again, I can't thank you enough for sticking with this as long as you have.
    I'm glad you managed to see some progress, if nothing else.
    I would be interested to see the VBA set-up that always works on smaller datasets, see what I can do to the data to isolate separate groups potentially.
    Can you also remind me which formula was the original one? There have been so many iterations at this point, they all meld into one.

    Not sure about having better luck, I'm as newbie as it comes with anything more than the standard sum/average functions, and especially VBA, but enjoying getting stuck in and seeing what I can find.

    Once again, thank you!
    Take care and stay safe <3

  86. #86
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    The attached file contains both formula results (column C) and, once run via clicking the target icon, VBA results (column D).

    The macro brings in randomly generated data for ARRAY1 and ARRAY2 from the Random Entries Generator tab. If this is not desired then go into the VBA window and remove the line StringsforTesting from Sub Main().

    Conditional Formatting has been applied to the output range to aid inspection of results. Also, several defined names have been created within Name Manager which apply to various ranges within the workbook and also to subsections of the main formula.

    Regards
    Attached Files Attached Files

  87. #87
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    Noticed small error in previous file. Attached v2.

    Regards
    Attached Files Attached Files

  88. #88
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Combination of two iterative formula

    And here's a 15-column-by-140-row version.

    Whether this takes 30 seconds to run or 3 days all depends upon the particulars of your data.

    Regards
    Attached Files Attached Files

  89. #89
    Registered User
    Join Date
    04-27-2020
    Location
    UK
    MS-Off Ver
    2010
    Posts
    55

    Re: Combination of two iterative formula

    Hi XOR,

    Sorry it's been a while since I got back to you, I have been busy with a few other things so I haven't had a decent amount of time to work on this, and am only really just coming to it. Thank you again for sending them all over to me, I am looking through them at the moment, and trying to make the necessary changes to make it work.
    Looking into the formula first (still intimidated by the VBA), and seeing where that takes me.

    Will let you know how I get on

+ 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. Iterative COUNTIFS formula
    By giovyledzep in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-09-2018, 05:24 PM
  2. Iterative formula to calculate minimum foundation depths
    By bengineering in forum Excel General
    Replies: 4
    Last Post: 07-28-2017, 04:41 AM
  3. Help with iterative formula to avoid circular reference
    By Soco15 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-14-2017, 01:17 PM
  4. Iterative Formula
    By kathrynreno in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-29-2016, 09:23 PM
  5. [SOLVED] Need help with iterative Debt to Capital formula
    By AudiR8dreamer in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-20-2015, 11:36 AM
  6. Create an iterative formula
    By leonszlez in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-22-2012, 06:12 PM
  7. Iterative Formula
    By Phil_V in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-14-2009, 08:54 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