Sub reception()
'
' trie Macro
'
'
Rows("1:1").Select
Selection.AutoFilter
nbLignes = ActiveSheet.Cells(Rows.count, "A").End(xlUp).Row 'Détermine le nombre de ligne qu'il y a dans le fichier excel
If Application.CountIf(Columns("O:O"), "GB*") > 0 Then
ActiveSheet.Range("$A$1:$X$" & nbLignes).AutoFilter Field:=15, Criteria1:= _
"GB*"
Rows("2:" & nbLignes).Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent6
.PatternTintAndShade = 0
End With
ActiveSheet.Range("$A$1:$X$" & nbLignes).AutoFilter Field:=15
End If
If Application.CountIf(Columns("F:F"), "*TRANSPORT*") > 0 Then 'Condition si dans la colonne désignation article il y a des articles contenant le mot transport
ActiveSheet.Range("$A$1:$X$" & nbLignes).AutoFilter Field:=6, Criteria1:= _
"*TRANSPORT*" 'Trie et filtre tous ces articles
Rows("2:" & nbLignes).Select 'Selectionne les articles filtrer
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent2 'Les met en couleurs
.PatternTintAndShade = 0
End With
End If
If Application.CountIf(Columns("F:F"), "PRESTATION*") > 0 Then
ActiveSheet.Range("$A$1:$X$" & nbLignes).AutoFilter Field:=6, Criteria1:= _
"PRESTATION*"
Rows("2:" & nbLignes).Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent2
.PatternTintAndShade = 0
End With
End If
If Application.CountIf(Columns("F:F"), "PACKAGING*") > 0 Then
ActiveSheet.Range("$A$1:$X$" & nbLignes).AutoFilter Field:=6, Criteria1:= _
"PACKAGING*"
Rows("2:" & nbLignes).Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent2
.PatternTintAndShade = 0
End With
End If
If Application.CountIf(Columns("F:F"), "FRAIS**") > 0 Then
ActiveSheet.Range("$A$1:$X$" & nbLignes).AutoFilter Field:=6, Criteria1:= _
"FRAIS*"
Rows("2:" & nbLignes).Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent2
.PatternTintAndShade = 0
End With
End If
If Application.CountIf(Columns("F:F"), "GESTION DE*") > 0 Then
ActiveSheet.Range("$A$1:$X$" & nbLignes).AutoFilter Field:=6, Criteria1:= _
"GESTION DE*"
Rows("2:" & nbLignes).Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent2
.PatternTintAndShade = 0
End With
End If
If Application.CountIf(Columns("F:F"), "HM da*") > 0 Then
ActiveSheet.Range("$A$1:$X$" & nbLignes).AutoFilter Field:=6, Criteria1:= _
"HM da*"
Rows("2:" & nbLignes).Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent2
.PatternTintAndShade = 0
End With
End If
If Application.CountIf(Columns("F:F"), "REGULARISATION*") > 0 Then
ActiveSheet.Range("$A$1:$X$" & nbLignes).AutoFilter Field:=6, Criteria1:= _
"REGULARISATION*"
Rows("2:" & nbLignes).Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent2
.PatternTintAndShade = 0
End With
End If
If Application.CountIf(Columns("F:F"), "FMEC*") > 0 Then
ActiveSheet.Range("$A$1:$X$" & nbLignes).AutoFilter Field:=6, Criteria1:= _
"FMEC*"
Rows("2:" & nbLignes).Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent2
.PatternTintAndShade = 0
End With
End If
If Application.CountIf(Columns("F:F"), "R&D*") > 0 Then
ActiveSheet.Range("$A$1:$X$" & nbLignes).AutoFilter Field:=6, Criteria1:= _
"R&D*"
Rows("2:" & nbLignes).Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent2
.PatternTintAndShade = 0
End With
End If
If Application.CountIf(Columns("F:F"), "GESTION ADMIN*") > 0 Then
ActiveSheet.Range("$A$1:$X$" & nbLignes).AutoFilter Field:=6, Criteria1:= _
"GESTION ADMIN*"
Rows("2:" & nbLignes).Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent2
.PatternTintAndShade = 0
End With
End If
If Application.CountIf(Columns("F:F"), "FORFAIT LIVR*") > 0 Then
ActiveSheet.Range("$A$1:$X$" & nbLignes).AutoFilter Field:=6, Criteria1:= _
"FORFAIT LIVR*"
Rows("2:" & nbLignes).Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent2
.PatternTintAndShade = 0
End With
End If
ActiveSheet.Range("$A$1:$X$" & nbLignes).AutoFilter Field:=6
ActiveWorkbook.Worksheets("Feuil1").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Feuil1").AutoFilter.Sort.SortFields.Add(Range( _
"F1:F" & nbLignes), xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue.Color _
= RGB(255, 255, 153)
With ActiveWorkbook.Worksheets("Feuil1").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub