Hello,
could you please help me with the VBA code as I am trying to get a separate column calculating the mean of all the possible combinations of 25C5 (i.e. 53130 combinations in total).
Here is the code I am using but I do not know what to do to get my results? D column are my 25 prices that I want to calculate the mean of each 5 prices of all the possible combinations out of the set of 25 prices.
Sub ListThemAll()
TC = 1
TR = 1
Ctr = 1
MaxRows = Rows.Count
EndCell = 53130
Application.ScreenUpdating = False
For a = 1 To 25
For b = (a + 1) To 22
For c = (b + 1) To 23
For d = (c + 1) To 24
For e = (d + 1) To 25
Application.StatusBar = Ctr & " on way to " & EndCell
Cells(TR, TC).Value = a & "-" & b & "-" & c & "-" & d & "-" & e
Ctr = Ctr + 1
If Ctr Mod 25000 = 0 Then
Cells(TR - 20, TC).Select
Application.ScreenUpdating = True
ThisWorkbook.Save
Application.ScreenUpdating = False
End If
TR = TR + 1
If TR = MaxRows Then
TR = 1
TC = TC + 1
End If
Next e
Next d
Next c
Next b
Next a
Application.StatusBar = False
Application.ScreenUpdating = True
End Sub
This is what I am trying to achieve on the attached file and I am at 1715 combination but manually it will take me a long time.
could you please help me with the VBA code as I am trying to get a separate column calculating the mean of all the possible combinations of 25C5 (i.e. 53130 combinations in total).
Here is the code I am using but I do not know what to do to get my results? D column are my 25 prices that I want to calculate the mean of each 5 prices of all the possible combinations out of the set of 25 prices.
Sub ListThemAll()
TC = 1
TR = 1
Ctr = 1
MaxRows = Rows.Count
EndCell = 53130
Application.ScreenUpdating = False
For a = 1 To 25
For b = (a + 1) To 22
For c = (b + 1) To 23
For d = (c + 1) To 24
For e = (d + 1) To 25
Application.StatusBar = Ctr & " on way to " & EndCell
Cells(TR, TC).Value = a & "-" & b & "-" & c & "-" & d & "-" & e
Ctr = Ctr + 1
If Ctr Mod 25000 = 0 Then
Cells(TR - 20, TC).Select
Application.ScreenUpdating = True
ThisWorkbook.Save
Application.ScreenUpdating = False
End If
TR = TR + 1
If TR = MaxRows Then
TR = 1
TC = TC + 1
End If
Next e
Next d
Next c
Next b
Next a
Application.StatusBar = False
Application.ScreenUpdating = True
End Sub
This is what I am trying to achieve on the attached file and I am at 1715 combination but manually it will take me a long time.