Aide sur une macro

Je suis débutant, et j'aurais besoin d'aide sur une macro qui génère une erreur lorsque qu'il ne trouve pas de résultat.

Il faut que j’introduise la fonction If.

Private Sub CommandButtonSearch_Click()

Dim Lign As Long

With Sheets("Saisie")

Lign = .Columns(8).Cells.Find(TextBox1).Row

Me.TextBox2 = .Cells(Lign, 1)

Me.TextBox3 = .Cells(Lign, 2)

Me.TextBox4 = Cells(Lign, 3)

Me.TextBox5 = Cells(Lign, 4)

Me.TextBox6 = Cells(Lign, 5)

Me.TextBox7 = Cells(Lign, 6)

Me.TextBox8 = Cells(Lign, 7)

Me.TextBox9 = Cells(Lign, 8)

Me.TextBox12 = Cells(Lign, 9)

Me.TextBox13 = Cells(Lign, 16)

'Me.Oui = Cells(Lign, 15)

End With

End Sub

Merci pour votre aide.

Bonjour et bienvenue sur le forum

Tu devrais joindre ton fichier.

Bye !

Bonjour,

Essaie ainsi :

Private Sub CommandButtonSearch_Click()
Dim Cell As Range, Lign As Long
    With ActiveWorkbook.Worksheets("Saisie")
        On Error Resume Next
        Set Cell = .Columns(8).Find(TextBox1.Text, xlValues, xlWhole)
        On Error GoTo 0
        If Cell Is Nothing Then
            MsgBox "La valeur recherchée n'existe pas !...", vbInformation, "Information"
            Exit Sub
        Else
            Lign = Cell.Row
            Me.TextBox2 = .Cells(Lign, 1)
            Me.TextBox3 = .Cells(Lign, 2)
            Me.TextBox4 = Cells(Lign, 3)
            Me.TextBox5 = Cells(Lign, 4)
            Me.TextBox6 = Cells(Lign, 5)
            Me.TextBox7 = Cells(Lign, 6)
            Me.TextBox8 = Cells(Lign, 7)
            Me.TextBox9 = Cells(Lign, 8)
            Me.TextBox12 = Cells(Lign, 9)
            Me.TextBox13 = Cells(Lign, 16)
            'Me.Oui = Cells(Lign, 15)
        End If
    End With
End Sub

Merci Jean-Eric

J'ai essayé mais cela ne marche pas.

Dans tous les cas il affiche "La valeur recherchée n'existe pas !..."

il ne fait pas la recherche sur la colonne.

Voici le fichier

C'est la fonction recherche

Bonjour,

Essaie ainsi :

Set Cell = .Columns(8).Find(what:=TextBox1.Text, LookIn:=xlValues, lookat:=xlWhole)

Super

Je te remercie Jean-Eric pour ton aide

C'est exactement ce que je recherchais

@+

Rechercher des sujets similaires à "aide macro"