Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi everyone,
I will give this request one last try and put it as simply as I can without all the confusing and complicated jargon. I have the following wheel of 6 number combinations in Cells "B3:G12" in a sheet named "Data". 01 02 03 04 05 06 01 07 08 09 10 11 01 12 13 14 15 16 02 03 07 08 12 13 02 03 09 10 14 15 04 05 07 08 14 15 04 05 09 10 12 13 02 03 04 05 11 16 06 07 08 09 10 16 06 11 12 13 14 15 I want to iterate through ( see the code below ) ALL the 5 number combinations produced from "n" ( "n" = the highest number used in ANY of the 6 number combinations which is 16, so C(16,5) = 4,368 combinations ) and compare each 5 number combination with each 6 number combination in the wheel above. If at "LEAST" 2 numbers match then add 1 to the 2 if 5 category total ( total to go in Cell "D12" in the sheet named " Statistics" ). If at "LEAST" 3 numbers match then add 1 to the 3 if 5 category total ( total to go in Cell "D16" in the sheet named "Statistics" ). If at "LEAST" 4 numbers match then add 1 to the 4 if 5 category total ( total to go in Cell "D19" in the sheet named "Statistics" ). If ALL 5 numbers match then add 1 to the 5 if 5 category total ( total to go in Cell "D21" in the sheet named "Statistics" ). If ANY of the 5 number combinations does NOT match ANY of the 6 number combinations with the required scenario of ? if 5, then that 5 number combination is NOT covered for that particular scenario of ? if 5 and therefore 1 ( one ) cannot be added to the respective ? if 5 category total. That is it in a nutshell really. I have written the following code which might be of use :- Option Explicit Option Base 1 Sub Produce_5_Number_Combinations() Dim A As Integer Dim B As Integer Dim C As Integer Dim D As Integer Dim E As Integer Dim MinVal As Integer Dim MaxVal As Integer Application. ScreenUpdating = False MinVal = 1 MaxVal = Whatever the highest number In the sheet named "Data" And In the Range "B3:G?" is. For A = 1 To MaxVal - 4 For B = A + 1 To MaxVal - 3 For C = B + 1 To MaxVal - 2 For D = C + 1 To MaxVal - 1 For E = D + 1 To MaxVal *** Code goes here maybe *** Next E Next D Next C Next B Next A *** Output totals For Each category *** Application.ScreenUpdating = True End Sub I hope this helps. Thanks in Advance. All the Best. Paul |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here is some code to do factorial. Modify as needed. think about your
instructions below if the are correct. I will help modify the code if you need more help Public FactArray(5) Const MaxValue = 16 Const MaxWidth = 5 Const MyColumn = "F" Sub test() Factorial (1) End Sub Sub Factorial(Depth) For Count = 1 To MaxValue 'make sure number isn't in FactArray Found = False For i = 0 To (Depth - 1) If FactArray(i) = Count Then Found = True Exit For End If Next i If Found = False Then FactArray(Depth - 1) = Count If Depth = MaxWidth Then Printstring = FactArray(0) For j = 1 To (Depth - 1) Printstring = Printstring & "," & _ FactArray(j) Next j MsgBox (Printstring) Else Factorial (Depth + 1) End If End If Next Count End Sub "Paul Black" wrote: Hi everyone, I will give this request one last try and put it as simply as I can without all the confusing and complicated jargon. I have the following wheel of 6 number combinations in Cells "B3:G12" in a sheet named "Data". 01 02 03 04 05 06 01 07 08 09 10 11 01 12 13 14 15 16 02 03 07 08 12 13 02 03 09 10 14 15 04 05 07 08 14 15 04 05 09 10 12 13 02 03 04 05 11 16 06 07 08 09 10 16 06 11 12 13 14 15 I want to iterate through ( see the code below ) ALL the 5 number combinations produced from "n" ( "n" = the highest number used in ANY of the 6 number combinations which is 16, so C(16,5) = 4,368 combinations ) and compare each 5 number combination with each 6 number combination in the wheel above. If at "LEAST" 2 numbers match then add 1 to the 2 if 5 category total ( total to go in Cell "D12" in the sheet named " Statistics" ). If at "LEAST" 3 numbers match then add 1 to the 3 if 5 category total ( total to go in Cell "D16" in the sheet named "Statistics" ). If at "LEAST" 4 numbers match then add 1 to the 4 if 5 category total ( total to go in Cell "D19" in the sheet named "Statistics" ). If ALL 5 numbers match then add 1 to the 5 if 5 category total ( total to go in Cell "D21" in the sheet named "Statistics" ). If ANY of the 5 number combinations does NOT match ANY of the 6 number combinations with the required scenario of ? if 5, then that 5 number combination is NOT covered for that particular scenario of ? if 5 and therefore 1 ( one ) cannot be added to the respective ? if 5 category total. That is it in a nutshell really. I have written the following code which might be of use :- Option Explicit Option Base 1 Sub Produce_5_Number_Combinations() Dim A As Integer Dim B As Integer Dim C As Integer Dim D As Integer Dim E As Integer Dim MinVal As Integer Dim MaxVal As Integer Application. ScreenUpdating = False MinVal = 1 MaxVal = Whatever the highest number In the sheet named "Data" And In the Range "B3:G?" is. For A = 1 To MaxVal - 4 For B = A + 1 To MaxVal - 3 For C = B + 1 To MaxVal - 2 For D = C + 1 To MaxVal - 1 For E = D + 1 To MaxVal *** Code goes here maybe *** Next E Next D Next C Next B Next A *** Output totals For Each category *** Application.ScreenUpdating = True End Sub I hope this helps. Thanks in Advance. All the Best. Paul |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
compare cells, copy, loop | Excel Worksheet Functions | |||
Loop Down Columns and Compare Values | Excel Programming | |||
Loop,Compare,Write | Excel Programming | |||
Loop and Compare | Excel Programming | |||
Excel VBA - Help with a loop, compare, delete problem | Excel Programming |