Bonjour à tous,
Il était question d'une condition sur l'énoncé du sujet. Je pense que cette condition doit être l'existence du fichier :
dim tpath() as string
With Worksheets("Dossier")
dl = .cells(.rows.count, 1).end(xlup).row
For i = 4 To dl
If dir(.cells(i, 1).value) <> "" Then
ReDim Preserve tpath(w)
tpath(w) = .cells(i, 1).Value
w = w + 1
End If
Next i
End With
if w = 0 then msgbox "aucun fichier existant repertorié", 16: exit sub
list2 = Array(0, 2, 3, 6, 7, 8, 20, 21, 22)
list3 = Array(2, 3, 4, 7, 8, 9, 11, 12, 13)
Item = InputBox("item")
'================================================================================================
'''''''''''''''''''''alimentation des données''''''''''''''''''''''''''''''''''''''''
ReDim tdata(UBound(tpath), UBound(list2))
For i = LBound(tpath) To UBound(tpath)
With Workbooks.Open(tpath(i), 0)
With .Sheets(1)
Set x = .Columns(1).Find(Item, , xlValues, xlWhole)
For J = LBound(list2) To UBound(list2)
tdata(i, J) = .Cells(x.Row, x.Column + list2(J))
Next J
End With
.Close True
End With
Next i
J'ai changé de nom car List est une propriété pour certains objets. Cela pourrait occasionner une erreur de compilation. D'ailleurs, si possible, il faut essayer de donner aux variables des noms désignant le contenu (ici des chemins).
Sinon, j'ai remis tpath en base 0 car tous les tableaux étaient en base 0 dans le code.
Cdlt,