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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| Sub Recherche_barre()
Dim DerLig_i As Long, DerLig_A As Long, DerLig_N As Long, i As Long, L As Long
Application.ScreenUpdating = False
DerLig_i = [I10000].End(xlUp).Row
DerLig_A = [A10000].End(xlUp).Row
Range("N2:R1000").ClearContents
For L = 2 To DerLig_i
Barre = Cells(L, "i")
Longueur = Cells(L, "j")
Largeur = Cells(L, "K")
'Epaisseur = Cells(l, "L")
DerLig_N = [N10000].End(xlUp).Row
For i = 2 To DerLig_A
If Cells(i, "A") = Barre And Cells(i, "B") >= Longueur And Cells(i, "C") >= Largeur Then
Cells(DerLig_N + 1, "N") = Barre
Cells(DerLig_N + 1, "O") = Cells(i, "B") 'Longueur
Cells(DerLig_N + 1, "P") = Cells(i, "C") 'Largeur
Cells(DerLig_N + 1, "Q") = Cells(i, "D") 'Epaisseur
Cells(DerLig_N + 1, "R") = Cells(i, "E") 'Lieu
DerLig_N = DerLig_N + 1
End If
Next i
Next L
'tri
Range("N2:R" & DerLig_N).Select
ActiveWorkbook.Worksheets("stock").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("stock").Sort.SortFields.Add Key:=Range("N2:N" & DerLig_N), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("stock").Sort.SortFields.Add Key:=Range("O2:O" & DerLig_N), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("stock").Sort.SortFields.Add Key:=Range("P2:P" & DerLig_N), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("stock").Sort.SortFields.Add Key:=Range("Q2:Q" & DerLig_N), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("stock").Sort.SortFields.Add Key:=Range("R2:R" & DerLig_N), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("stock").Sort
.SetRange Range("N2:R" & DerLig_N)
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
'Suppression des doublons
For i = DerLig_N To 2 Step -1
If Cells(i, "N") = Cells(i - 1, "N") And Cells(i, "O") = Cells(i - 1, "O") And Cells(i, "P") = Cells(i - 1, "P") And Cells(i, "Q") = Cells(i - 1, "Q") And Cells(i, "R") = Cells(i - 1, "R") Then Range(Cells(i, "N"), Cells(i, "R")).Delete
Next i
End Sub |
Partager