LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 394
Default Loop, Compare, Match & Total

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

 
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
compare cells, copy, loop Immortal_Creations Excel Worksheet Functions 2 July 17th 09 03:34 PM
Loop Down Columns and Compare Values DrwRob28 Excel Programming 5 August 15th 06 06:21 PM
Loop,Compare,Write Michael168[_75_] Excel Programming 1 May 25th 04 06:41 PM
Loop and Compare JWolf Excel Programming 2 May 12th 04 04:01 PM
Excel VBA - Help with a loop, compare, delete problem rippy Excel Programming 0 February 4th 04 03:38 PM


All times are GMT +1. The time now is 07:12 AM.

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"