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 41 42 43
| Private Sub Worksheet_Activate()
Dim Dico As Object, item As String, c As Range
Set Dico = CreateObject("Scripting.Dictionary")
'plage fournisseurs
With Sheets("BD")
For Each c In .Range(.[B2], .Cells(.Rows.Count, 2).End(xlUp))
If Not Dico.exists(c.Value) Then
Dico.Add c.Value, c.Value
End If
Next c
Sheets("Consultation").[U1].Resize(Dico.Count) = Application.Transpose(Dico.items)
End With
Sheets("Consultation").Select
Shapes.Range("Drop Down 8").Select
With Selection
.ListFillRange = Range("U1").Resize(Dico.Count).Address
.LinkedCell = "$G$1"
.DropDownLines = 8
End With
End Sub
Private Sub Worksheet_Calculate()
Dim Dico As Object, item As String, c As Range
Set Dico = CreateObject("Scripting.Dictionary")
Sheets("Consultation").Select
With Sheets("BD")
If [Consultation!G1] = "" Then Exit Sub
For Each c In .Range(.[C2], .Cells(.Rows.Count, 3).End(xlUp))
If Not Dico.exists(c.Value) And c.Offset(, -1) = _
Application.Index([U:U], [Consultation!G1]) Then
Dico.Add c.Value, c.Value
End If
Next c
Application.EnableEvents = False
[Consultation!V1].Resize(Dico.Count) = Application.Transpose(Dico.items)
Sheets("Consultation").Shapes.Range("Drop Down 1").Select
End With
With Selection
.ListFillRange = Range("V1").Resize(Dico.Count).Address
.LinkedCell = "$H$1"
.DropDownLines = 8
End With
Application.EnableEvents = True
End Sub |
Partager