Quelqu'un de sympa sur ce forum m'a écrit la macro suivante (voir + bas).
En gros, elle prend 6 cellules au hasard dans la colonne A (entre A1 et A32)
et les recopie sur la ligne A35 (entre A35 et A40).
Plutôt que de les recopier systématiquement sur la ligne A35, je souhaiterais
plutôt qu'elle recopie ces 6 cellules sur de la première ligne vide A PARTIR
de la ligne A35 comprise.
(Exemple, si les lignes A35 et A36 ne sont pas vides, alors la macro copiera
les 6 cellules sur la ligne A37).
Une idée ?
Merci !
Bien Cordialement,
Christian
----------------------------------------
Option Explicit
Option Base 1
Sub Choix6()
'
Dim Tablo
Dim Result()
Dim Cell As Range
Dim i%, Indice%
'
Application.ScreenUpdating = False
' Tablo = Range("B1:B" & Range("B65536").End(xlUp).Row)
Tablo = Range("A1:A32")
ReDim Result(1 To UBound(Tablo))
i = 1
Do While i <= 6
Indice = Int(Rnd * 32 + 1)
If Result(Indice) = 0 Then
Result(Indice) = 1
i = i + 1
End If
Loop
Set Cell = Range("A35")
For i = 1 To UBound(Tablo)
If Result(i) Then
Cell = Tablo(i, 1)
Set Cell = Cell.Offset(0, 1)
End If
Next i
Range("A35").Select
Application.ScreenUpdating = True
End Sub
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
JLuc
*Bonjour nospam*,
---------------------------------------- Option Explicit Option Base 1
Sub Choix6() ' Dim Tablo Dim Result() Dim Cell As Range Dim i%, Indice% ' Application.ScreenUpdating = False ' Tablo = Range("B1:B" & Range("B65536").End(xlUp).Row) Tablo = Range("A1:A32") ReDim Result(1 To UBound(Tablo)) i = 1 Do While i <= 6 Indice = Int(Rnd * 32 + 1) If Result(Indice) = 0 Then Result(Indice) = 1 i = i + 1 End If Loop Set Cell = Range("A" & Range("A65536").End(xlup).Row + 1)
For i = 1 To UBound(Tablo) If Result(i) Then Cell = Tablo(i, 1) Set Cell = Cell.Offset(0, 1) End If Next i Range("A35").Select Application.ScreenUpdating = True End Sub Devrait convenir, dis nous ;-)
-- ____ ( O | O ) -- _oooO_ JLuc _Oooo_
O-O
*Bonjour nospam*,
----------------------------------------
Option Explicit
Option Base 1
Sub Choix6()
'
Dim Tablo
Dim Result()
Dim Cell As Range
Dim i%, Indice%
'
Application.ScreenUpdating = False
' Tablo = Range("B1:B" & Range("B65536").End(xlUp).Row)
Tablo = Range("A1:A32")
ReDim Result(1 To UBound(Tablo))
i = 1
Do While i <= 6
Indice = Int(Rnd * 32 + 1)
If Result(Indice) = 0 Then
Result(Indice) = 1
i = i + 1
End If
Loop
Set Cell = Range("A" & Range("A65536").End(xlup).Row + 1)
For i = 1 To UBound(Tablo)
If Result(i) Then
Cell = Tablo(i, 1)
Set Cell = Cell.Offset(0, 1)
End If
Next i
Range("A35").Select
Application.ScreenUpdating = True
End Sub
Devrait convenir, dis nous ;-)
---------------------------------------- Option Explicit Option Base 1
Sub Choix6() ' Dim Tablo Dim Result() Dim Cell As Range Dim i%, Indice% ' Application.ScreenUpdating = False ' Tablo = Range("B1:B" & Range("B65536").End(xlUp).Row) Tablo = Range("A1:A32") ReDim Result(1 To UBound(Tablo)) i = 1 Do While i <= 6 Indice = Int(Rnd * 32 + 1) If Result(Indice) = 0 Then Result(Indice) = 1 i = i + 1 End If Loop Set Cell = Range("A" & Range("A65536").End(xlup).Row + 1)
For i = 1 To UBound(Tablo) If Result(i) Then Cell = Tablo(i, 1) Set Cell = Cell.Offset(0, 1) End If Next i Range("A35").Select Application.ScreenUpdating = True End Sub Devrait convenir, dis nous ;-)