P
Paul Black
Bernie, thanks ever so much for all the time and effort you have given
to this, it is appreciated.
Just a couple of things though please.
I am going over to see my niece this evening so I will be able to run
the two Subs you provided below ( the second one has been updated
according to your last response ).
Firstly, for Private Sub Gaps2(), will it possible to have the Grand
Total for ALL the combinations produced in column "C" please . This
figure will be 69,919,080 as produced by Mr. Tom Ogilvy when he kindly
ran the Sub for me and will go after the last entry in Column "C".
Secondly, will it be possible for Private Sub Gaps4() to have ...
Sheets("Gaps Data").Range("B2").Value = "Gaps"
Sheets("Gaps Data").Range("C2").Value = "Total"
.... and the categories list starting in Cell "B3" and the Total
combinations associated with each category starting in Cell "C3"
like ...
Column "B" Column "C"
00 00 00 00 01 xxx,xxx,xxx
00 00 08 03 02 xxx,xxx,xxx
09 08 02 02 03 xxx,xxx,xxx
.... for example.
Finally, will it also be possible to have the Grand Total for ALL the
combinations produced in column "C" please, this will go after the
last entry in Column "C".
Private Sub Gaps2()
Dim A As Integer
Dim B As Integer
Dim C As Integer
Dim D As Integer
Dim E As Integer
Dim F As Integer
Dim i As Integer
Dim GapsTotal(0 To 43) As Long
Application.ScreenUpdating = False
For i = 0 To 43
GapsTotal(i) = 0
Next i
For A = 1 To 44
For B = A + 1 To 45
For C = B + 1 To 46
For D = C + 1 To 47
For E = D + 1 To 48
For F = E + 1 To 49
GapsTotal(B - A - 1) = GapsTotal(B - A - 1) + 1
GapsTotal(C - B - 1) = GapsTotal(C - B - 1) + 1
GapsTotal(D - C - 1) = GapsTotal(D - C - 1) + 1
GapsTotal(E - D - 1) = GapsTotal(E - D - 1) + 1
GapsTotal(F - E - 1) = GapsTotal(F - E - 1) + 1
Next F
Next E
Next D
Next C
Next B
Next A
Sheets("Gaps Data").Range("B2").Value = "Gaps"
Sheets("Gaps Data").Range("C2").Value = "Total"
For i = 0 To 43
Sheets("Gaps Data").Cells(i + 3, 2).Value = "Gaps of " & Format(i,
"00")
Sheets("Gaps Data").Cells(i + 3, 3).Value = GapsTotal(i)
Next i
Application.ScreenUpdating = True
End Sub
---------------------------------------------------------------------
Private Sub Gaps4()
Dim A As Integer
Dim B As Integer
Dim C As Integer
Dim D As Integer
Dim E As Integer
Dim i As Integer
Dim mySize As Integer
Dim strGap As String
Dim myCol As Integer
Dim myRow As Long
Dim myCell As Range
Application.ScreenUpdating = False
'
myCol = 1
myRow = 1
mySize = 49 'start with a lower number here to try it....
Cells.ClearContents
For A = 0 To mySize - 5
For B = 0 To mySize - 5 - A
For C = 0 To mySize - 5 - B - A
For D = 0 To mySize - 5 - C - B - A
For E = 0 To mySize - 5 - D - C - B - A
If mySize - 5 - A - B - C - D - E > 0 Then
strGap = Format(A, "00") & " " & _
Format(B, "00") & " " & _
Format(C, "00") & " " & _
Format(D, "00") & " " & _
Format(E, "00") & " Count = " & Format(mySize - 5 - A - B - C - D -
E,
"0")
Cells(myRow, myCol).Value = strGap
myRow = myRow + 1
If myRow = Rows.Count + 1 Then
myRow = 1
myCol = myCol + 1
End If
End If
Next E
Next D
Next C
Next B
Next A
Application.ScreenUpdating = True
End Sub
I will then be able to run them later as I said.
Thanks in Advance.
All the Best.
Paul
to this, it is appreciated.
Just a couple of things though please.
I am going over to see my niece this evening so I will be able to run
the two Subs you provided below ( the second one has been updated
according to your last response ).
Firstly, for Private Sub Gaps2(), will it possible to have the Grand
Total for ALL the combinations produced in column "C" please . This
figure will be 69,919,080 as produced by Mr. Tom Ogilvy when he kindly
ran the Sub for me and will go after the last entry in Column "C".
Secondly, will it be possible for Private Sub Gaps4() to have ...
Sheets("Gaps Data").Range("B2").Value = "Gaps"
Sheets("Gaps Data").Range("C2").Value = "Total"
.... and the categories list starting in Cell "B3" and the Total
combinations associated with each category starting in Cell "C3"
like ...
Column "B" Column "C"
00 00 00 00 01 xxx,xxx,xxx
00 00 08 03 02 xxx,xxx,xxx
09 08 02 02 03 xxx,xxx,xxx
.... for example.
Finally, will it also be possible to have the Grand Total for ALL the
combinations produced in column "C" please, this will go after the
last entry in Column "C".
Private Sub Gaps2()
Dim A As Integer
Dim B As Integer
Dim C As Integer
Dim D As Integer
Dim E As Integer
Dim F As Integer
Dim i As Integer
Dim GapsTotal(0 To 43) As Long
Application.ScreenUpdating = False
For i = 0 To 43
GapsTotal(i) = 0
Next i
For A = 1 To 44
For B = A + 1 To 45
For C = B + 1 To 46
For D = C + 1 To 47
For E = D + 1 To 48
For F = E + 1 To 49
GapsTotal(B - A - 1) = GapsTotal(B - A - 1) + 1
GapsTotal(C - B - 1) = GapsTotal(C - B - 1) + 1
GapsTotal(D - C - 1) = GapsTotal(D - C - 1) + 1
GapsTotal(E - D - 1) = GapsTotal(E - D - 1) + 1
GapsTotal(F - E - 1) = GapsTotal(F - E - 1) + 1
Next F
Next E
Next D
Next C
Next B
Next A
Sheets("Gaps Data").Range("B2").Value = "Gaps"
Sheets("Gaps Data").Range("C2").Value = "Total"
For i = 0 To 43
Sheets("Gaps Data").Cells(i + 3, 2).Value = "Gaps of " & Format(i,
"00")
Sheets("Gaps Data").Cells(i + 3, 3).Value = GapsTotal(i)
Next i
Application.ScreenUpdating = True
End Sub
---------------------------------------------------------------------
Private Sub Gaps4()
Dim A As Integer
Dim B As Integer
Dim C As Integer
Dim D As Integer
Dim E As Integer
Dim i As Integer
Dim mySize As Integer
Dim strGap As String
Dim myCol As Integer
Dim myRow As Long
Dim myCell As Range
Application.ScreenUpdating = False
'
myCol = 1
myRow = 1
mySize = 49 'start with a lower number here to try it....
Cells.ClearContents
For A = 0 To mySize - 5
For B = 0 To mySize - 5 - A
For C = 0 To mySize - 5 - B - A
For D = 0 To mySize - 5 - C - B - A
For E = 0 To mySize - 5 - D - C - B - A
If mySize - 5 - A - B - C - D - E > 0 Then
strGap = Format(A, "00") & " " & _
Format(B, "00") & " " & _
Format(C, "00") & " " & _
Format(D, "00") & " " & _
Format(E, "00") & " Count = " & Format(mySize - 5 - A - B - C - D -
E,
"0")
Cells(myRow, myCol).Value = strGap
myRow = myRow + 1
If myRow = Rows.Count + 1 Then
myRow = 1
myCol = myCol + 1
End If
End If
Next E
Next D
Next C
Next B
Next A
Application.ScreenUpdating = True
End Sub
I will then be able to run them later as I said.
Thanks in Advance.
All the Best.
Paul