Bonjour le forum,
J'ai un problème que je n'arrive pas à résoudre pour la recherche de valeur dans un tableau dynamique.
Mon fichier est ici :
Mon problème est dans le code du formulaire UserFormConfFle. Lorsque je clic sur le bouton valider le flexible une ligne se créer dans la feuille "flexible" et mon second bur est de mettre à jour les stocks avec cette confirmation. Pour la mise a jour du stock des raccords, je reçois erreur 91, variable objet ou variable de bloc with non définie et je ne comprend pas pourquoi...
D'après le mode pas à pas c'est cette ligne qui poserait problème :
refr1 = raccord.Columns(B).Find(bds.Range("A18"), LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows).Row
Je commence seulement le vba donc il y a surement qqch que j'utilise mal puisque la source est un tableau...
Et voici le code complet :
Private Sub cmdconffle_Click()
finf = Sheets("flexible").Range("A" & Rows.Count).End(xlUp).Row
Dim bds As Worksheet
Dim tuyau As Worksheet
Dim raccord As Worksheet
Dim douille As Worksheet
Set tuyau = Sheets("tuyau")
Set douille = Sheets("douille")
Set raccort = Sheets("raccord")
Set bds = Sheets("Bon de sortie")
fint = tuyau.Range("A" & Rows.Count).End(xlUp).Row
'finr = raccord.Range("A" & Rows.Count).End(xlUp).Row
Find = douille.Range("A" & Rows.Count).End(xlUp).Row
With Sheets("flexible")
.Range("A" & finf + 1) = finf
.Range("B" & finf + 1) = Date
.Range("C" & finf + 1) = bds.Range("B1")
.Range("D" & finf + 1) = bds.Range("B2")
.Range("E" & finf + 1) = "fabriquant"
.Range("F" & finf + 1) = bds.Range("B5")
.Range("G" & finf + 1) = bds.Range("B6")
.Range("H" & finf + 1) = bds.Range("B7")
.Range("I" & finf + 1) = bds.Range("B13")
.Range("J" & finf + 1) = bds.Range("A13")
.Range("K" & finf + 1) = bds.Range("A24")
.Range("L" & finf + 1) = bds.Range("A18")
If bds.Range("A19") = "" Then
.Range("M" & finf + 1) = bds.Range("A18")
Else: .Range("M" & finf + 1) = bds.Range("A19")
End If
.Range("N" & finf + 1) = "En attente Facturation"
End With
reft = tuyau.Range("E2:E" & fint).Find(bds.Range("A13"), LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows).Row
tuyau.Range("F" & reft) = tuyau.Range("F" & reft) - bds.Range("B13")
refd = douille.Range("A2:E" & Find).Find(bds.Range("A24"), LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows).Row
douille.Range("G" & refd) = douille.Range("G" & refd) - bds.Range("B24")
refr1 = raccord.Columns(B).Find(bds.Range("A18"), LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows).Row
raccord.Range("L" & refr1) = raccord.Range("L" & finr1) - bds.Range("A18")
If bds.Range("A19") <> "" Then
refr2 = raccord.Columns(B).Find(bds.Range("A19"), LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows).Row
raccord.Range("L" & refr2) = raccord.Range("L" & finr2) - bds.Range("A19")
End If
Unload UserFormConfFle
End Sub
J'ai vraiment besoin d'utiliser un tableau, cela me permet de faire des recherches rapides en utilisant les filtres. Mon tableau représente un stock et sera à s'allonger dans le temps donc j'aimerais utiliser une fonction qui tienne compte de ca...
qqun aurait il une idée ou la bonne ligne de code pour que je puisse continuer à avancer svp ?
Merci d'avance !