Bonjour,
J'ai un ComboBox qui fonctionne mais j'aimerais l'adapter avec la colonne F qui comporte des chiffres (F3:F900)
Codes avec texte sur colonne B (pour exemple) :
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 Private Sub ComboBox1_Change() Application.ScreenUpdating = False Dim Plage As Range Dim Cel As Range Set Plage = [B3:B900] For Each Cel In Plage If Cel.Value = ComboBox1.Value Then Rows(Cel.Row).Hidden = False Else Rows(Cel.Row).Hidden = True End If Next Application.ScreenUpdating = True End Sub
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 Private Sub UserForm_Initialize() Dim ws As Worksheet Dim rng As Range Dim dict As Object Dim i As Long Dim key As Variant Set ws = ThisWorkbook.Sheets("Interventions techniques") Set rng = ws.Range("B3", ws.Cells(ws.Rows.Count, "B").End(xlUp)) Set dict = CreateObject("Scripting.Dictionary") For i = 1 To rng.Count If Not dict.Exists(rng(i, 1).Value) Then dict.Add rng(i, 1).Value, Nothing End If Next i For Each key In SortedKeys(dict.keys) ComboBox1.AddItem key Next key End SubMerci.
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 Private Function SortedKeys(keys As Variant) As Variant Dim i As Long Dim j As Long Dim temp As Variant Dim arr() As Variant arr = keys For i = LBound(arr) To UBound(arr) - 1 For j = i + 1 To UBound(arr) If arr(i) > arr(j) Then temp = arr(i) arr(i) = arr(j) arr(j) = temp End If Next j Next i SortedKeys = arr End Function
Bonne journée
Partager