Bouton recherche -Modifier-supprimer(erreur: 80070057)

Bonjour à tous,

Merci pour votre aide.

Toujours sur mon fichier et j'ai encore besoin de vos aides.

J'ai un bouton Recherche pour en cas besoin soit modifier soit supprimer les infos du formulaire.

(Code pris sur ce forum et adapté à mon cas)Code Bouton recherche:

Private Sub T1_Change()

Dim i&, fin&, y&, a&, mem As Boolean

Application.ScreenUpdating = 0

If mem1 Then Exit Sub

If T1 = "" Then ListBox1.Clear: T1 = "": C3.Visible = 0: C4.Visible = 0: Exit Sub

ListBox1.Clear

With Sheet2

y = 1

fin = .Range("A" & Rows.Count).End(xlUp).Row

aa = .Range("A9:AT" & fin)

End With

For i = 1 To UBound(aa)

aa(i, 45) = i + 1

Next i

For i = 1 To UBound(aa)

For a = 1 To UBound(aa, 2)

If aa(i, a) Like "*" & T1 & "*" Then aa(i, 6) = "oui": y = y + 1: Exit For

Next a

Next i

If y = 1 Then Exit Sub

If y = 2 Then

For i = 1 To UBound(aa)

If aa(i, 44) = "oui" Then

ListBox1.AddItem aa(i, 1)

For a = 1 To UBound(aa, 2) - 2

ListBox1.List(ListBox1.ListCount - 1, a - 1) = aa(i, a)

Controls("T" & a + 1) = aa(i, a)

Next a

mem = 1: Exit For

End If

Next i

Else

ReDim bb(y - 1, UBound(aa, 2) - 1)

y = 1

For i = 1 To UBound(aa)

If aa(i, 6) = "oui" Then

For a = 1 To UBound(aa, 2) - 1

bb(y, a) = aa(i, a)

Next a

y = y + 1

End If

Next i

End If

With ListBox1

.ColumnCount = 45

.ColumnWidths = "80;80;50;80;80;80;80;50;80;80;80;80;50;80;80;80;80;50;80;80;80;80;50;80;80;80;80;50;80;80;80;80;50;80;80;80;80;50;80;80;80;80;50;80;80"

If mem Then Exit Sub

.List = bb

End With

End Sub

Code Bouton Modifier:

Private Sub C4_Click()

Dim rep, memo$

If ListBox1.ListIndex = -1 Then Exit Sub

rep = MsgBox("Attention Voulez vous rééllement supprimer la ligne sélectionnée??", vbYesNo, "Suppression de ligne")

If rep = vbNo Then Exit Sub

memo = T1

Sheet2.Rows(ListBox1.List(ListBox1.ListIndex, 45)).Delete

Unload SAISIR

SAISIR.T1 = memo

SAISIR.Show

End Sub

code bouton modifier :

Private Sub C3_Click()

Dim lig&, i&, memo$

If ListBox1.ListIndex = -1 Then Exit Sub

lig = ListBox1.List(ListBox1.ListIndex, 45)

With Sheet2

For i = 1 To 45

If IsNumeric(Controls("T" & i + 1)) Then

Sheet2.Cells(lig, i) = Controls("T" & i + 1) * 1

Else

Sheet2.Cells(lig, i) = Controls("T" & i + 1)

End If

Next i

End With

memo = T1

Unload SAISIR

SAISIR.T1 = memo

SAISIR.Show

End Sub

Code listbox:

Private Sub ListBox1_Click()

Dim i&, lig&

If ListBox1.ListIndex = -1 Then Exit Sub

For i = 1 To 45

mem1 = 1

Controls("T" & i + 1) = ListBox1.List(ListBox1.ListIndex, i - 1)

Next i

C4.Visible = 1: C3.Visible = 1

mem1 = 0

End Sub

Merci et desolé pour ce long code

Salut le Forum

Tu n'auras pas beaucoup d'aide sans fournir de fichier.

Mytå

Salut Myta,

Tout à fait d'accord avec toi. Merci pour la franchise et pour ton aide.

Voici le lien:

Rechercher des sujets similaires à "bouton recherche modifier supprimer erreur 80070057"