Bonjour,
Proposition :
Sub ReportAge()
Dim age(), n%, i%, j%
With Worksheets("Sheet1")
n = WorksheetFunction.CountIf(.Columns("C"), "Y")
ReDim age(n, 1)
n = .Cells(.Rows.Count, 3).End(xlUp).Row
.Range("A2:C" & n).Sort key1:=.Range("A2"), order1:=xlAscending, Header:=xlNo
For i = 2 To n
If .Cells(i, 3) = "Y" Then
j = j + 1
age(j, 0) = .Cells(i, 1)
age(j, 1) = .Cells(i, 2)
End If
Next i
End With
With Worksheets("Sheet2")
n = .Cells(.Rows.Count, 1).End(xlUp).Row
.Range("A1:B" & n).Sort key1:=.Range("A1"), order1:=xlAscending, Header:=xlNo
j = 1
For i = 1 To n
If .Cells(i, 1) = age(j, 0) Then
.Cells(i, 2) = age(j, 1)
j = j + 1
If j > UBound(age, 1) Then Exit Sub
ElseIf .Cells(i, 1) > age(j, 0) Then
MsgBox age(j, 0) & " ne figure pas dans la base.", vbInformation, "Elément manquant"
j = j + 1: i = i - 1
If j > UBound(age, 1) Then Exit Sub
End If
Next i
End With
End Sub
Cordialement.