1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| Sub Findq(CIBLE, Ligne, WBC)
Dim Val As Range
Dim i As Long, k As Long
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set WBS = Workbooks.Open("C:\Documents\Desktop\recap.xls")
With WBS.Worksheets(2)
k = .Cells(.Rows.Count, 1).End(xlUp).Row
Set Val = .Range(.Cells(1, 1), .Cells(k, 1)).Find(CIBLE, LookIn:=xlValues)
If Not Val Is Nothing Then
i = Val.Row
Do
WBC.Worksheets(3).Range("C" & Ligne) = .Cells(Val.Row, 12).Value
Ligne = Ligne + 1
If i = k Then GoTo 1
Set Val = .Range(.Cells(i, 1), .Cells(k, 1)).Find(CIBLE, LookIn:=xlValues)
If Val Is Nothing Then GoTo 1
If Val.Row = i Then GoTo 1
i = Val.Row
Loop
Else
GoTo 1
End If
End With
1
WBS.Save
WBS.Close
Set WBS = Nothing
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub |
Partager