ComboBox - problème de code

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) :

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

    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

Merci.

Bonjour,

Dans ta Private Sub ComboBox1_Change(), remplace :

Set Plage = [B3:B900]

par :

Set Plage = [F3:F900]

et :

If Cel.Value = ComboBox1.Value Then

par :

If Cel.Text = ComboBox1.Value Then

Un grand merci.

Bonne journée.

Rechercher des sujets similaires à "combobox probleme code"