Option Explicit

Private Sub CommandButton4_Click()
    Dim ws1 As Worksheet, ws2 As Worksheet
    Dim intCount As Long
    Dim s As Long, n As Long
    
    Set ws1 = Worksheets("Sheet1")
    Set ws2 = Worksheets("Sheet2")
    s = WorksheetFunction.Sum(ws2.Range("A1:A6"))

    Randomize

    For intCount = 15 To 150
        ws1.Range("B2").Value = intCount
        n = Int(s / intCount)
        ws1.Range("B3").Value = Int(n * Rnd + 1)
        If ws1.Range("B4").Value = "Akkoord; voldoende steken" Then
            Unload Me
            Exit Sub
        End If
    Next
     
End Sub