Un grand merci.
Pour d'autres recherches j'ai des ComboBox mais j'ai essayé avec la colonne F (chiffres) et je n'ai pas trouvé comment l'adapter.
Codes avec texte sur colonne B (pour exemple) :
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
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 Sub
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
' Trier le tableau
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