[FONT=Courier New][SIZE=1]Option Explicit[/SIZE][/FONT]
[FONT=Courier New][SIZE=1]Public Sub Generate6ex49()[/SIZE][/FONT]
[SIZE=1][FONT=Courier New]Const MainSheet As String = "[COLOR=red][B]Sheet1[/B][/COLOR]"[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Const SheetPrefix As String = "[COLOR=red][B]Part[/B][/COLOR]"[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Const SplitPoint As Long = [COLOR=red][B]1000000[/B][/COLOR][/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Const HighBall As Integer = 49[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Dim iPtr As Integer[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Dim sFileName As String[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Dim SheetNumber As Integer[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Dim iRow As Long[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Dim iRec As Long[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Dim iLastRow As Long[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Dim ws As Worksheet[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Dim sMessage As String[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Dim sTime As Date[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Dim p1 As Integer[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Dim p2 As Integer[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Dim p3 As Integer[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Dim p4 As Integer[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Dim p5 As Integer[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Dim p6 As Integer[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]For Each ws In ThisWorkbook.Worksheets[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]If Left(ws.Name, Len(SheetPrefix)) = SheetPrefix Then[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] Application.DisplayAlerts = False[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] On Error Resume Next[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] ws.Delete[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] On Error GoTo 0[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] Application.DisplayAlerts = True[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]End If[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Next ws[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Sheets(MainSheet).Columns("A:B").ClearContents[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]sMessage = vbCrLf & "Workbook reset. Proceed to create combination records?" _[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] & Space(10) & vbCrLf & vbCrLf _[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] & "Warning: this will take several minutes!"[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]If MsgBox(sMessage, vbYesNo + vbQuestion) = vbNo Then[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Exit Sub[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]End If[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Sheets(MainSheet).Range("A1:B1").Font.Bold = True[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Sheets(MainSheet).Range("A1") = "Worksheet"[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Sheets(MainSheet).Range("B1") = "Records"[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]sTime = Now()[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]SheetNumber = 0[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]iRow = SplitPoint[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]iRec = 0[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]For p1 = 1 To HighBall - 5[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]For p2 = p1 + 1 To HighBall - 4[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] For p3 = p2 + 1 To HighBall - 3[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] For p4 = p3 + 1 To HighBall - 2[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] For p5 = p4 + 1 To HighBall - 1[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] For p6 = p5 + 1 To HighBall[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] iRec = iRec + 1[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] iRow = iRow + 1[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] If iRow > SplitPoint Then[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] If SheetNumber > 0 Then[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] iLastRow = Sheets(MainSheet).Cells(Rows.Count, 1).End(xlUp).Row[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] Sheets(MainSheet).Cells(iLastRow, 2) = iRow - 1[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] End If[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] SheetNumber = SheetNumber + 1[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] Sheets.Add(After:=Sheets(Sheets.Count)).Name = SheetPrefix & Right("00" & CStr(SheetNumber), 3)[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] Sheets(MainSheet).Activate[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] iLastRow = Sheets(MainSheet).Cells(Rows.Count, 1).End(xlUp).Row[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] Set ws = Sheets(SheetPrefix & Right("00" & CStr(SheetNumber), 3))[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] Sheets(MainSheet).Cells(iLastRow + 1, 1) = ws.Name[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] iRow = 1[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] End If[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] ws.Cells(iRow, 1) = p1[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] ws.Cells(iRow, 2) = p2[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] ws.Cells(iRow, 3) = p3[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] ws.Cells(iRow, 4) = p4[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] ws.Cells(iRow, 5) = p5[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] ws.Cells(iRow, 6) = p6[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] DoEvents[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] Next p6[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] Next p5[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] Next p4[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] Next p3[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Next p2[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Next p1[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Sheets(MainSheet).Cells(iLastRow + 1, 2) = iRow[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Sheets(MainSheet).Cells(iLastRow + 2, 1) = "Total"[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Sheets(MainSheet).Cells(iLastRow + 2, 2) = iRec[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Sheets(MainSheet).Columns("A:B").EntireColumn.AutoFit[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]Sheets(MainSheet).Range("A1").Select[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]MsgBox vbCrLf & Format(iRec, "#,###") & " records created" & Space(10) & vbCrLf & vbCrLf _[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] & CStr(SheetNumber) & " worksheets created" & vbCrLf & vbCrLf _[/FONT][/SIZE]
[SIZE=1][FONT=Courier New] & "Run time: " & Format(Now() - sTime, "hh:nn:ss"), vbOKOnly + vbInformation[/FONT][/SIZE]
[FONT=Courier New][SIZE=1]End Sub[/SIZE][/FONT]