View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
RB Smissaert RB Smissaert is offline
external usenet poster
 
Posts: 2,452
Default Using Excel for statistical analysis - a question for problem-solvers

Hi Peter,

Yes, you are right there, but the loop is useful if you want a fixed number
of items less than the
total number of all items as then it won't be a simple calculation.

RBS


"Peter T" <peter_t@discussions wrote in message
...
Hi Bart,

There are 1048575 possible combinations then:


looks remarkably like
items = 20
= 2 ^ items - 1

Regards,
Peter T


"RB Smissaert" wrote in message
...
There are 1048575 possible combinations then:

Sub Test()

Dim lItems As Long
Dim i As Long
Dim lCombinations As Long

lItems = 20

For i = 1 To lItems
lCombinations = lCombinations + _
Application.WorksheetFunction.Combin(lItems, i)
Next i

MsgBox lCombinations, , _
"unique combinations with " & lItems & " items"

End Sub


RBS


wrote in message
...
I am not sure precisely what you are asking. Hopefully, one of the
following points will help clarify my problem (sorry!)"

1. I would never use any single variable twice in a single
combination. There would never be a Var5+Var5+Var+1.

2. The order of the variables in a combination is irrelevent. For my
purposes the string Var1+Var2+Var3 is equal to both Var3+Var2+Var1 and
Var2+Var3+Var1. If, however, for programming purposes the duplicates
could not be removed, I could probably make do with them.

I hope that makes it a bit clearer.