Attribute VB_Name = "Main" Public DataArray() As Integer Public QuickArray() As Integer Public ArrCount As Long Public SpinsPerSheet As Integer Public NumberOfSheets As Integer Public SampleSize As Long Public FilePathI As String 'Const FileNmI = "MillionSpins" Public Const FileNmI = "mt19937arVBAout" Public bReadingFromMersenne As Boolean Sub Main() Dim X As Integer Dim S As String Dim R As String Dim TotCold As Long Dim TotChar As Long Dim TotLead2 As Long Dim TotLead3 As Long Dim TotLead2Char As Long Dim TotLead3Char As Long Dim Result10K As Integer Dim Chart As Long FilePathI$ = "C:\Users\Owner\Downloads\" & FileNmI & ".txt" NumberOfSheets = 10 SpinsPerSheet = 1000 SampleSize = SpinsPerSheet * NumberOfSheets ReDim DataArray(SampleSize) ReDim QuickArray(SpinsPerSheet - 1) bReadingFromMersenne = True ArrCount = 0 Chart = 0 Debug.Print "X"; "Result10K", "Chart", "TotLead2", "TotLead3", "TotLead2Char", "TotLead3Char" For X = 301 To 400 S = Trim(Str(X + 8)) R = "A" & S & ":AP" & S Distribute Calculate Sheets("List").Range(R).Value2 = Sheets("List").Range("A8:AP8").Value2 Result10K = Sheets("Together").Range("AD1").value Chart = Chart + Result10K TotCold = Sheets("List").Range("AK8").Value2 TotChar = TotChar + TotCold TotLead2 = Sheets("List").Range("AO8").Value2 TotLead3 = Sheets("List").Range("AP8").Value2 TotLead2Char = TotLead2Char + TotLead2 TotLead3Char = TotLead3Char + TotLead3 Debug.Print X; Result10K, Chart, TotLead2, TotLead3, TotLead2Char, TotLead3Char 'y = x - 9 'y = y Mod 100 'If y = 0 Then Debug.Print x - 9 & " of 1000" Next X 'M = MsgBox("keep going?", vbYesNo) 'If M = 7 Then Exit Sub 'ActiveWorkbook.Save End Sub Sub Distribute() Dim i As Integer Dim y As Integer Dim Adj1 As Integer Dim Adj2 As Integer Dim LinesConsumed As Long Dim ShString As String Adj2 = 0 Const StartOnRow = 19 If Not bReadingFromMersenne Then FilePathI = "C:\Users\Owner\Downloads\" & FileNmI & ".txt" LinesConsumed = ReadLinesIntoPublicArray(FilePathI, SampleSize, ArrCount + 1) ArrCount = ArrCount + LinesConsumed End If If bReadingFromMersenne Then mainMersenne FilePathI$, SampleSize, DataArray End If For i = 1 To NumberOfSheets ShString = "Sh" & Trim(Str(i)) For y = 0 To SpinsPerSheet - 1 QuickArray(y) = DataArray(Adj2) If y = 999 Then End If Adj2 = Adj2 + 1 Next y Sheets(ShString).Range("A19:A1018").value = WorksheetFunction.Transpose(QuickArray) Adj2 = i * SpinsPerSheet Next i End Sub Function ReadLinesIntoPublicArray(File, SampleSize, BeginningAt) As Long Dim Count As Long Dim CountNumbersYes As Long Dim CountNumbersNon As Long Dim CountLines As Long Dim N CountNumbersYes = 0 CountNumbersNon = 0 CountLines = 0 Count = 0 N = FreeFile Open File For Input As #N Do While Not EOF(N) Count = Count + 1 Line Input #N, strLine If Count >= BeginningAt Then If Left(strLine, 1) = Chr(34) Then strLine = Mid(strLine, 2, 1) Else strLine = Left(strLine, 2) End If If IsNumeric(strLine) = False Then CountNumbersNon = CountNumbersNon + 1 Else DataArray(CountNumbersYes) = CInt(strLine) CountNumbersYes = CountNumbersYes + 1 End If If CountNumbersYes = SampleSize Then Exit Do End If Loop Close ReadLinesIntoPublicArray = CountNumbersYes + CountNumbersNon End Function