Moderatori: Anthony47, Flash30005
Anthony ha scritto:Mi hai confuso: se ci sono 231 combinazioni, come facciamo a riempire 11*231 celle?
Karistotele ha scritto:Sono impazzito!!!
Le 231 combinazioni si esauriscono con 11 COLONNE e 21 RIGHE
Sub comb11col()
Dest = "P" '<<< la colonna dove comincera' l' elenco
'
Range(Dest & 1).Resize(1000, 11).Clear
For I = 1 To 22
For J = I + 1 To 22
Range(Dest & Rows.Count).Offset(0, pippo Mod 11).End(xlUp).Offset(1, 0) = _
Range("A2").Offset(I, 0) & Range("A2").Offset(J, 0)
pippo = pippo + 1
Next J
Next I
End Sub
Sub CombinaD()
R1 = 1
Dim Vn(22) As String
For RV = 1 To 22
Vn(RV) = Range("A" & RV).Value
Next RV
Columns("C:X").ClearContents
For RR1 = 1 To 21
For RR2 = RR1 + 1 To 22
Cells(R1, 3).Value = Vn(RR1)
Cells(R1, 4).Value = Vn(RR2)
R1 = R1 + 1
If R1 = 232 Then R1 = 1
Next RR2
Next RR1
For RR = 1 To 231
UC = 0
Ini:
If UC >= 20 Then GoTo SaltaRR
Randomize
NC = Vn(Int(Rnd() * 22) + 1)
For CC = 3 To 24
If Cells(RR, CC).Value = NC Then GoTo Ini
If Cells(RR, CC).Value = "" Then
Cells(RR, CC).Value = NC
UC = UC + 1
GoTo Ini
End If
Next CC
SaltaRR:
Next RR
End Sub
Sub comb2a2()
Dim ListA1 As String, Dest As String, MyVArr, DynArr, Rispo, aaa
Dim LstList As Integer, Player As Integer, I As Integer, J As Integer
'Parametri
ListA1 = "A2" 'La cella dove comincia l' elenco dei componenti
Dest = "C2" 'l' area delle combinazioni
'
RePlayer:
LstList = Range(ListA1).Offset(100, 0).End(xlUp).Row
Player = LstList - Range(ListA1).Row + 1
If Player Mod 2 = 1 Then
Range(ListA1).Offset(Player) = "Rip"
GoTo RePlayer
End If
If Player < 4 Or Player > 30 Then
MsgBox ("Almeno 4 e max 30 Player (ora sono " & Player & "); operazione interrotta")
Exit Sub
End If
MyVArr = Range(ListA1).Resize(Player, 1).Value
Range(Dest).Resize(Player + 10, Player + 3).Select
Rispo = MsgBox("Ok per azzerare l' area selezionata?" & vbCrLf & _
"SI per continuare, NO per interrompere", vbYesNo)
If Rispo <> vbYes Then Exit Sub
Selection.Clear
Selection.Range("A1").Select
'inizializza dynArr
DynArr = Range(Dest).Resize(Player - 1, Player).Value
I = UBound(DynArr, 2)
For I = 0 To Player / 2 - 1
DynArr(1, 1 + I * 2) = 1 + I: DynArr(1, 1 + I * 2 + 1) = Player - I
Next I
For I = 2 To Player - 1
For J = 2 To Player
DynArr(I, J) = (DynArr(I - 1, J) - 3 + 2 * (Player - 1)) Mod (Player - 1) + 2
Next J
Next I
For I = 2 To Player - 1
DynArr(I, 1) = 1
Next I
'scrivi in Dest
For I = 1 To Player - 1
For J = 1 To Player
With Range(Dest).Offset(I - 1, J - 1)
.Value = MyVArr(DynArr(I, J), 1)
If Int((J - 1) / 2) Mod 2 = 0 Then .Interior.Color = RGB(0, 200, 200)
'Range(Dest).Resize(Player - 1, Player) = DynArr
End With
Next J
Next I
End Sub
Torna a Applicazioni Office Windows
Calcolo numero giorni settimana nel periodo Autore: Ricky0185 |
Forum: Applicazioni Office Windows Risposte: 16 |
Calcolo del Bitrate per un formato CD Autore: franco11 |
Forum: Audio/Video e masterizzazione Risposte: 4 |
Visitano il forum: Raffaele53 e 13 ospiti