Sub maekake() Range("A1") = "価格" Range("B1") = "キャンセル回数" Range("C1") = "利益" Range("D1") = "時間" Range("E1") = "利益/時間" Range("F1") = "総利益" Range("G1") = "総時間" Range("H1") = "秒間平均利益" Const cansel_timeloss As Single = 3.68 Const fastest_time As Single = 14.92 Dim price As Integer Dim profit As Single Dim time As Single Dim bokechance As Integer Dim i As Long Dim k As Integer For i = 1 To 50000 k = 0 Do bokechance = WorksheetFunction.RandBetween(0, 31) If bokechance = 0 Then price = WorksheetFunction.RoundDown(1500 * WorksheetFunction.RandBetween(96, 128) / 64, 0) Exit Do Else price = WorksheetFunction.RoundDown(1500 * WorksheetFunction.RandBetween(54, 80) / 64, 0) If price >= 1687 Then Exit Do Else k = k + 1 End If End If Loop profit = price - 1507.14 time = fastest_time + cansel_timeloss * k Cells(i + 1, 1) = price Cells(i + 1, 2) = k Cells(i + 1, 3) = profit Cells(i + 1, 4) = time Cells(i + 1, 5) = profit / time Next i Range("F2") = "=SUM(C2:C50001)" Range("G2") = "=SUM(D2:D50001)" Range("H2") = "=F2/G2" End Sub