Moderatori: Anthony47, Flash30005
Sub aggruppa2()
Dim eUno As Long, eDue As Long, Elem As Long, gSize As Long, flRip As Boolean
Dim gCount As Long, cgCount As Long, Odds As Long, uArr() As Integer, Cas As Long
Dim cSize As Long
gSize = Sheets("Elenco").Range("G1")
eUno = Application.WorksheetFunction.CountA(Sheets("Elenco").Range("B:B")) - 1
eDue = Application.WorksheetFunction.CountA(Sheets("Elenco").Range("D:D")) - 1
Elem = eUno + 2 * eDue
gCount = Int(Elem / gSize)
Odds = Elem - gCount * gSize
ReDim uArr(1 To Elem)
Sheets("Gruppi").Cells.ClearContents
mytim = Timer
For I = 1 To gCount
cSize = gSize
If (gCount - I) < Odds And Odds > 0 Then cSize = cSize + 1
For j = 1 To cSize
reCas:
Cas = Int(Rnd() * (eUno + eDue)) + 1
reCheck:
DoEvents
If (Timer - mytim) > 10 Then Stop: mytim = Timer
If uArr(Cas) <> 0 Then
Cas = (Cas + 1) Mod (eUno + eDue + 1)
If Cas = 0 Then Cas = 1
flRip = True
Else
flRip = False
End If
If flRip Then GoTo reCheck
If Cas > eUno And (cSize - j) < 1 Then GoTo reCas
If Cas > eUno Then
Sheets("Gruppi").Range("A1").Offset(100, I).End(xlUp).Offset(1, 0).Value = Sheets("Elenco").Range("D1").Offset(Cas - eUno, 0)
j = j + 1
two = True
Else
Sheets("Gruppi").Range("A1").Offset(100, I).End(xlUp).Offset(1, 0).Value = Sheets("Elenco").Range("B1").Offset(Cas, 0)
two = False
End If
uArr(Cas) = Cas
lastcas = Cas
Next j
Next I
Exit Sub
Debug.Print "logger:"
For k = 1 To Elem
If uArr(k) = 0 Then Debug.Print k
Next k
End Sub
Torna a Applicazioni Office Windows
Macro modifica date scelta periodo Autore: Ricky0185 |
Forum: Applicazioni Office Windows Risposte: 11 |
Supporto per sviluppo macro VBA Ordinare per data Autore: Carletto Ribolla |
Forum: Applicazioni Office Windows Risposte: 3 |
Inserire add.in nella barra di avvio veloce in excel 2003 Autore: Ricky0185 |
Forum: Applicazioni Office Windows Risposte: 4 |
Excel: problema con date se devo unirle a testi Autore: valle1975 |
Forum: Applicazioni Office Windows Risposte: 5 |
Visitano il forum: Nessuno e 24 ospiti