Sub Extraction()
Semaine = [B2]
N°_Carte = [F2]
Articles = [H2]
[A7:J65000].ClearContents
lig = 7
If Semaine = "" Then
For Each sh In Worksheets
If Left(sh.Name, 1) = "B" Then
With Sheets(sh.Name)
For k = 5 To .[A65000].End(3).Row
If .Cells(k, 3) = N°_Carte And .Cells(k, 8) = Articles Then
Sheets("Extraction").Range("A" & lig & ":J" & lig).Value = .Range("A" & k & ":J" & k).Value
lig = lig + 1
End If
Next
End With
End If
Next
Exit Sub
End If
If N°_Carte = "" Then
For Each sh In Worksheets
If Left(sh.Name, 1) = "B" Then
With Sheets(sh.Name)
For k = 5 To .[A65000].End(3).Row
If .Cells(k, 7) = Semaine And .Cells(k, 8) = Articles Then
Sheets("Extraction").Range("A" & lig & ":J" & lig).Value = .Range("A" & k & ":J" & k).Value
lig = lig + 1
End If
Next
End With
End If
Next
Exit Sub
End If
If Articles = "" Then
For Each sh In Worksheets
If Left(sh.Name, 1) = "B" Then
With Sheets(sh.Name)
For k = 5 To .[A65000].End(3).Row
If .Cells(k, 3) = N°_Carte And .Cells(k, 7) = Semaine Then
Sheets("Extraction").Range("A" & lig & ":J" & lig).Value = .Range("A" & k & ":J" & k).Value
lig = lig + 1
End If
Next
End With
End If
Next
Exit Sub
End If
'tous
For Each sh In Worksheets
If Left(sh.Name, 1) = "B" Then
With Sheets(sh.Name)
For k = 5 To .[A65000].End(3).Row
If .Cells(k, 3) = N°_Carte And .Cells(k, 7) = Semaine And .Cells(k, 8) = Articles Then
Sheets("Extraction").Range("A" & lig & ":J" & lig).Value = .Range("A" & k & ":J" & k).Value
lig = lig + 1
End If
Next
End With
End If
Next
End Sub