Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 394
Default Loop & Calculate

Hi Everyone,

Six Numbers are drawn.
The code below cycles through a range of Six Number Combinations and
produces a value of those covered for Five if Five is matched.
It basically tests for how many Five Number Combinations are covered in
the Fifteen Six Number Combinations ( Cells G13:L27 ) with Numbers One
to Twenty Four.
There are 42,504 Five Number Combinations of Twenty Four Numbers (
=COMBIN(24,5) ).
The code below produces a value of those that are covered out of the
42,504 Combinations ( Ninety, which is correct ).
How can the code below be adapted to ALSO calculate ( value to go in
Cell O17 ) how many Combinations are covered for Three if Five Please.
I was Told for the Interpretation of the 3 if 5 Category that you Need
to Cycle through ALL 5 Number Combinations that can be Constructed from
the Total Numbers Used in the Wheel ( 24 in this Case ). So if the
Wheel Contains "x" Unique Numbers, you Need to Cycle through ALL 5
Number Combinations from those "x" Numbers. Then you Need to Scan the
Wheel for Each 5 Number Combination Produced and Compare it with Each
Line in the Wheel to see if that Line Matches the 5 Number Combination
in *EXACTLY* 3 Numbers. If it does, then that Combination of 3 if 5 is
Covered and Added to the Total and there is NO Need to Continue to
Check for that Particular Combination Any Further. You then go onto the
Next Combination to Check and so on Until ALL Combinations have been
Cycled through and Checked with the Wheel.
I hope I have explained this clearly enough.
Here is the code :-

Sub test_for_5()
Dim a, dic As Object
Set dic = CreateObject("scripting.dictionary")
a = Range("G13").CurrentRegion.Value
For i = 1 To UBound(a, 1)
For ii = 1 To 2
For iii = ii + 1 To 3
For iv = iii + 1 To 4
For v = iv + 1 To 5
For vi = v + 1 To 6
z = a(i, ii) & "," & a(i, iii) & a(i, iv) &
a(i, v) & a(i, vi)
If Not dic.exists(z) Then
dic.Add z, Nothing
n = n + 1
End If
Next vi, v, iv, iii, ii, i
Set dic = Nothing
Range("O16") = n
End Sub

Thanks in Advance.
All the Best.
Paul

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
worksheet change infinite loop/calculate for user functions Mike[_2_] Excel Programming 2 February 17th 06 04:27 AM
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM
Loop Function unable to loop Junior728 Excel Programming 1 July 28th 05 10:23 AM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM
Loop expression to calculate return Jason Excel Programming 1 July 14th 04 01:27 AM


All times are GMT +1. The time now is 01:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"