Extraire l'année d'une date

bonsoir

j'ai une colonne = range("a2:a100) avec des dates sous forme ( ??/??/????) et j'ai un combobox1 des années (yyyy)

je veux faire une recherche suivant l'année

comment je peux dire si l'année de i in range("a2:a100") est égal à combobox1

j'ai fait

For Each i In Range("a4:a100")

If Format(CDate(i), "yyyy") = Me.ComboBox1 Then

mais ça ne marche pas

Bonjour,

Une piste. Je suis parti du principe que le ComboBox est un contrôle ActiveX :

Private Sub ComboBox1_Change()

    Dim Plage As Range
    Dim Cel As Range
    Dim Annee As Integer

    Annee = CInt(ComboBox1.Text)

    Set Plage = Range("A2:A100")

    Set Cel = Plage.Find(Annee, , xlFormulas, xlPart)

    If Not Cel Is Nothing Then MsgBox Cel.Address(0, 0)

End Sub

Bonjour,

Si tu as des dates :

    If Year(i) = CInt(ComboBox1.Value)
Rechercher des sujets similaires à "extraire annee date"