I tested this way, but fundamentally the order in which the numbers are being generated does not matter; you might want to shuffle them afterwards if necessary:
Sub M_snb() y = 300 ReDim sn(60, 5) For j = 0 To UBound(sn) Z = 0 For jj = 0 To UBound(sn, 2) - 1 sn(j, jj) = Int((y - Z) * Rnd) Z = Z + sn(j, jj) Next sn(j, jj) = y - Z Next Cells(1).Resize(UBound(sn) + 1, UBound(sn, 2) + 1) = sn End Sub




Reply With Quote