Bonjour au forum,
Avec le code suivant, je duplique le résultat X fois selon choix dans CBoxNombre dans le sens de la verticalet
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 Dim PDepart As String, Validite As String Dim TextEtiquette As String, PremLig As String, SecLig As String, TrLig As String Dim Indice As Integer, I As Integer Dim Ctl As Control If Me.CBoxNombre.ListIndex = -1 Then MsgBox "Veuillez indiquez une quantité" With CBoxNombre .BorderStyle = 1: .BorderColor = RGB(255, 0, 0) .SetFocus End With Exit Sub Else PDepart = A1 'Première ligne qui sera mise au format gras (voir plus bas) PremLig = CBoxProduit & " - " & CBoxMarque & Chr(10) 'Deuxième ligne sans modification du format SecLig = "Mise en conditionnement le : " & TxtBoxDate & Chr(10) 'Troisième ligne qui sera mise au format italique (voir plus bas) TrLig = "A consommer avant le " & TxtBoxDLC TextEtiquette = PremLig & SecLig & TrLig With Sheets(1) With .Range(PDepart) .Value = TextEtiquette 'Application de format pour les lignes ci dessus .Characters(Start:=1, Length:=Len(PremLig)).Font.Bold = True .Characters(Start:=Len(PremLig) + Len(SecLig), Length:=Len(TrLig)).Font.Italic = True End With Indice = ((.Range(PDepart).Row - 1) * 3) + .Range(PDepart).Column - 1 For I = 1 To Val(Me.CBoxNombre) - 1 Indice = Indice + 1 .Range(PDepart).Copy Destination:=.Cells(1 + (Indice) \ 3, 1 + ((Indice) Mod 3)) Next I End With End IfJe souhaite avec 2 optionbutton (horizontal et vertical)effectuer la copie soit à l' horizontal avec OptButtonH ou à la vertical avec OptButtonV.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 Private Sub UserForm_Initialize() Dim aa aa = Sheets("Listes").Range("I2:I" & Sheets("Listes").Range("I50").End(xlUp).Row) CBoxColonne.List = aa aa = Sheets("Listes").Range("J2:J" & Sheets("Listes").Range("J10").End(xlUp).Row) CBoxLigne.List = aa End Sub
Un peu compliqué pour mon niveau,
pouvez-vous m'aider ?
Merci
Stephanie
Partager