S.H.A.D.O.
Well-known Member
- Joined
- Sep 6, 2005
- Messages
- 1,915
Good evening,
What I am trying to do is to loop through ALL 6 number combinations and count how many Odd & Even numbers there are in each of the 6 positions.
For example, for number TEN I would like the total combinations where number TEN is Odd in position ONE, then number TEN is Even in position ONE, then number TEN is Odd in position TWO, then number TEN is Even in position TWO etc upto and including where number TEN is Odd in position SIX, then number TEN is Even in position SIX.
Obviously number TEN is Even, but out of the TWELVE columns of data for each of the numbers there will be SIX with a figure in it and SIX showing ZERO.
Here is the code I have so far but can't quite get it to work.
Thanks in advance.
What I am trying to do is to loop through ALL 6 number combinations and count how many Odd & Even numbers there are in each of the 6 positions.
For example, for number TEN I would like the total combinations where number TEN is Odd in position ONE, then number TEN is Even in position ONE, then number TEN is Odd in position TWO, then number TEN is Even in position TWO etc upto and including where number TEN is Odd in position SIX, then number TEN is Even in position SIX.
Obviously number TEN is Even, but out of the TWELVE columns of data for each of the numbers there will be SIX with a figure in it and SIX showing ZERO.
Here is the code I have so far but can't quite get it to work.
Thanks in advance.
Code:
Option Explicit
Option Base 1
Sub Odds_and_Evens_by_Position()
Dim A As Long, B As Long, C As Long, D As Long, E As Long, F As Long
Dim OddA As Long, OddB As Long, OddC As Long
Dim OddD As Long, OddE As Long, OddF As Long
Dim EvenA As Long, EvenB As Long, EvenC As Long
Dim EvenD As Long, EvenE As Long, EvenF As Long
Dim n As Long
With Sheets("Odd & Even").Select
Range("B:N").ClearContents
Range("B2").Select
For n = 1 To 30
For A = 1 To 25
If A Mod 2 = 1 Then OddA = OddA
If A Mod 2 = 0 Then EvenA = EvenA
For B = A + 1 To 26
If B Mod 2 = 1 Then OddB = OddB
If B Mod 2 = 0 Then EvenB = EvenB
For C = B + 1 To 27
If C Mod 2 = 1 Then OddC = OddC
If C Mod 2 = 0 Then EvenC = EvenC
For D = C + 1 To 28
If D Mod 2 = 1 Then OddD = OddD
If D Mod 2 = 0 Then EvenD = EvenD
For E = D + 1 To 29
If E Mod 2 = 1 Then OddE = OddE
If E Mod 2 = 0 Then EvenE = EvenE
For F = E + 1 To 30
If F Mod 2 = 1 Then OddF = OddF
If F Mod 2 = 0 Then EvenF = EvenF
OddA = OddA + 1
EvenA = EvenA + 1
OddB = OddB + 1
EvenB = EvenB + 1
OddC = OddC + 1
EvenC = EvenC + 1
OddD = OddD + 1
EvenD = EvenD + 1
OddE = OddE + 1
EvenE = EvenE + 1
OddF = OddF + 1
EvenF = EvenF + 1
Next F
Next E
Next D
Next C
Next B
Next A
Next
For n = 1 To 30
With ActiveCell
.Offset(2, 0).Value = n
.Offset(2, 1).Value = OddA
.Offset(2, 2).Value = EvenA
.Offset(2, 3).Value = OddB
.Offset(2, 4).Value = EvenB
.Offset(2, 5).Value = OddC
.Offset(2, 6).Value = EvenC
.Offset(2, 7).Value = OddD
.Offset(2, 8).Value = EvenD
.Offset(2, 9).Value = OddE
.Offset(2, 10).Value = EvenE
.Offset(2, 11).Value = OddF
.Offset(2, 12).Value = EvenF
.Offset(1, 0).Select
End With
Next n
End With
End Sub