Creating combinations using Excel -
i wondering if there function, or combination of functions (maybe requires vba) in excel me solve following problem:
there 8 people in group. need figure out , display of possible, non-repeating combinations created when 4 people selected out of 8. order of selected individuals isn’t important. need find of unique combinations.
for example: 8 people bob, carol, ted, alice, reed, sue, johnny, ben (cells a1 through a8 each contain 1 of names).
one combination bob, ted, reed, johnny. problem order of names isn’t important meaning bob, ted, reed, johnny same ted, bob, johnny, reed. combination of 4 people counts 1 instance.
i’m not trying figure out how many combinations possible. need see possible combinations.
i built binary evaluator:
public sub debugallcombinations(lpicksize long, spossibilities string, optional sdelimiter string = ";") dim long dim j long dim sbin string dim apossibilities() string dim lsum long dim lhitcount long apossibilities = split(spossibilities, sdelimiter) = 1 2 ^ (ubound(apossibilities) + 1) - 1 lsum = 0 sbin = worksheetfunction.dec2bin(i) j = 1 len(sbin) lsum = lsum + clng(mid(sbin, j, 1)) next j if lsum = lpicksize j = 1 len(sbin) if mid(sbin, j, 1) = "1" debug.print apossibilities(len(sbin) - j) & sdelimiter; next j debug.print lhitcount = lhitcount + 1 end if next debug.print lhitcount & " possibilities found" end sub
you can use this
debugallcombinations 4, "person1;person2;person3;person4;person5;person6;person7;person8"
it debug in immediate window
Comments
Post a Comment