Bonjour le forum, les intervenants,

Je reviens vers vous pour avoir un avis sur mon code.

La partie du code concerne le bouton valider de mon userform1.

Le but étant de copier/coller le contenu de mes 4 ComboBox sur mon fichier de saisie suivant certaines conditions.

Autrement dit : indiquer le même commentaire sur plusieurs lignes suivant conditions.

Voici mon code :

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
Ref1 = ActiveCell.Offset(0, -3) 'ligne H
    Ref2 = ActiveCell.Offset(0, -5) 'ligne F
    Ref3 = ActiveCell.Offset(0, -8) 'ligne C
    Ref4 = ActiveCell.Offset(0, -10) 'ligne A
    With Sheets("exemple")
         For i = 7 To [K10000].End(xlUp).Row
            If OptionButton1 = True Then
                 If Cells(i, "H") = Ref1 And Cells(i, "F") = Ref2 And Cells(i, "A") = Ref4 Then
                    If Me.ComboBox1 = "POSITIF" Then
                    .Range("O" & ActiveCell.Row & ":R" & ActiveCell.Row).Copy Destination:=Range("O" & i)
                    .Range("L" & ActiveCell.Row).Copy Destination:=Range("L" & i)
                    .Range("G" & i).Copy Destination:=Range("N" & i)
                    Else
                    .Range("O" & ActiveCell.Row & ":R" & ActiveCell.Row).Copy Destination:=Range("O" & i)
                    .Range("L" & ActiveCell.Row).Copy Destination:=Range("L" & i)
                    .Range("G" & i).Copy Destination:=Range("N" & i)
                     Range("N" & i).Select
                     Selection = Range("N" & i) * 0
                    End If
                End If
            End If
            If OptionButton2 = True Then
                 If Cells(i, "H") = Ref1 And Cells(i, "F") = Ref2 And Cells(i, "A") = Ref4 And Cells(i, "C") = Ref3 Then
                    If Me.ComboBox1 = "POSITIF" Then
                    .Range("O" & ActiveCell.Row & ":R" & ActiveCell.Row).Copy Destination:=Range("O" & i)
                    .Range("L" & ActiveCell.Row).Copy Destination:=Range("L" & i)
                    .Range("G" & i).Copy Destination:=Range("N" & i)
                    Else
                    .Range("O" & ActiveCell.Row & ":R" & ActiveCell.Row).Copy Destination:=Range("O" & i)
                    .Range("L" & ActiveCell.Row).Copy Destination:=Range("L" & i)
                    .Range("G" & i).Copy Destination:=Range("N" & i)
                     Range("N" & i).Select
                     Selection = Range("N" & i) * 0
                    End If
                End If
            End If
        Next i
    End With
Je vous remercie.

Je suis preneur de vos conseils.

Bonne journée le forum.