1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| Private Sub cboVilles_Change()
AdaptLboNoms
End Sub
Sub AdaptLboNoms()
Dim Target As Range
Dim Pos As Long, CountOf As Long
ClearTable "t_NomsVilleChoisie"
Set Target = Range("t_NomsVilleChoisie").ListObject.ListRows.Add().Range(1)
Target.Resize(Range("t_Contacts").Rows.Count, Range("t_Contacts").Columns.Count).Value = Range("t_Contacts").Value
With Range("t_NomsVilleChoisie").ListObject.Sort
.SortFields.Clear
.SortFields.Add Key:=Range("t_NomsVilleChoisie[Ville]"), Order:=xlAscending
.SortFields.Add Key:=Range("t_NomsVilleChoisie[Nom]"), Order:=xlAscending
.Apply
End With
Pos = Application.Match(cboVilles.Value, Range("t_NomsVilleChoisie[Ville]"), 0)
CountOf = Application.CountIfs(Range("t_NomsVilleChoisie[Ville]"), cboVilles.Value)
lboNoms.List = Range("t_NomsVilleChoisie[Nom]")(Pos).Resize(CountOf).Value
End Sub |
Partager