Combinar números
Publicado por Jairo (1 intervención) el 06/09/2015 19:04:31
Buenas si me ayudan a como convinar números del 1 al 35 en grupos de 5,sin que se repitan! Gracias
Valora esta pregunta


0
Option Explicit
Option Base 1
Private Const cMAX = 7
Sub Shuffle35()
Dim i%, j%
Dim col() As New Collection
Dim n As New Collection
On Error Resume Next
Cells.Clear
For i = 1 To 35
n.Add i
Next
ReDim col(cMAX) As New Collection
j = 1
Randomize
Do While (1)
With n
i = Int((.Count * Rnd) + 1)
col(j).Add .Item(i)
.Remove (i)
End With
If col(j).Count = 5 Then j = j + 1
If j > cMAX Then Exit Do
Loop
For j = 1 To cMAX
For i = 1 To 5
Range("A1").Offset(i - 1, j - 1) = col(j).Item(i)
Next
Next
Erase col
End Sub