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 39 40
|
Private Sub ComboBox1_Change()
Dim Cherche As String
Dim x As String, x1 As String, y As String
Dim c As Range
Unload Fiche
Sheets("BASE").Unprotect Password:="GSR"
If Me.ComboBox1.ListIndex > -1 Then
Cherche = Me.ComboBox1.Value
Sheets("F").Cells(1, 2) = Cherche
With Sheets("Base")
If .AutoFilterMode Then .Range("P2").AutoFilter
.Range("P2").AutoFilter field:=16, Criteria1:=Me.ComboBox1.Value
DerLig = .Cells(Rows.Count, "P").End(xlUp).Row
Application.ScreenUpdating = False
For Each c In .Range("P2:P" & DerLig).SpecialCells(xlCellTypeVisible)
x = c.Offset(0, -15) 'Reference
y = c.Offset(0, -14) 'Complement
With Sheets("F")
NoLig = .Range("A65535").End(xlUp).Row + 1
If NoLig > 3 Then
.Range(.Cells(NoLig - 1, "A"), .Cells(NoLig - 1, "B")).Copy Destination:=.Cells(NoLig, "A")
End If
.Range(.Cells(NoLig, "A"), .Cells(NoLig, "B")).ClearContents
If x <> x1 Then .Cells(NoLig, "A") = x Else .Cells(NoLig, "A") = "--"
.Cells(NoLig, "B") = y
End With
x1 = x
Next c
.Range("P2").AutoFilter
End With
End If
Application.ScreenUpdating = True
MsgBox (" Mise à jour faite !!")
End Sub |
Partager