Bonjour j'essaie d'optimiser un projet vba
J'ai commencé par réduire les selects
un erreur parait toujours je sais pas pourquoi
merci si vous pouvez me proposer des optimisations du code
Sub Macro1()
'
' Macro1 Macro
'
' Sub Miseàjour()
'
' Miseàjour Macro
'
' Suppression Filtre
Sheets("FS_semaine N").Select
Rows("1:1").Select
Selection.AutoFilter
' Arrangement onglet vierge (ordre croissant et colonnes rangées)
Sheets("vierge").Select
Cells.Select
' Selection.Columns.Ungroup
Columns("A:CJ").Select
Selection.EntireColumn.Hidden = False
Rows("1:7").Delete Shift:=xlUp
Cells.Select
With Selection
.WrapText = True
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("Y2").FormulaR1C1 = _
"=IF(ISBLANK(R[1]C[-10]),CONCATENATE(RC[-1],"" "",R[1]C[-1]),RC[-1])"
Range("Y2").AutoFill Destination:=Range("Y2:Y10000"), Type:=xlFillDefault
Columns("Y:Y").Copy
Columns("Y:Y").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Columns("Y:Y").Select
Application.CutCopyMode = False
Selection.Copy
Columns("X:X").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("AB2").FormulaR1C1 = _
"=IF(RC[-1]=""INITIALIZATION"",RC[3],IF(RC[-1]=""INSTRUCTION"",RC[5],IF(RC[-1]=""DEVELOPMENT"",RC[7],IF(RC[-1]=""OFFICIALIZATION - INDUSTRIALIZATION"",RC[9],RC[10]))))"
Range("AB2").AutoFill Destination:=Range("AB2:AB10000"), Type:=xlFillDefault
Columns("AB:AB").Copy
Columns("AB:AB").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Columns("AB:AB").Select
Application.CutCopyMode = False
Rows("1:1").Select
ActiveWindow.LargeScroll ToRight:=2
Columns("A:N").Select
Range("N1").Delete Shift:=xlToLeft
Columns("B:B").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("B2").FormulaR1C1 = "=IF(VALUE(RC[-1])=0,"""",VALUE(RC[-1]))"
Range("B2").AutoFill Destination:=Range("B2:B10000"), Type:=xlFillDefault
Columns("B:B").Copy
Columns("B:B").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Columns("A:A").Select
Range("A1").Delete Shift:=xlToLeft
ActiveWorkbook.Worksheets("vierge").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("vierge").AutoFilter.Sort.SortFields.Add Key:=Range _
("A1"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("vierge").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Rows("1:1").AutoFilter
Columns("E:E").Copy
Columns("B:B").Paste
Columns("I:I").Select
Application.CutCopyMode = False
Selection.Copy
Columns("D").Paste
Columns("F:F").Select
Application.CutCopyMode = False
Selection.Copy
Columns("C:C").Paste
Application.CutCopyMode = False
Columns("M:M").Select
Application.CutCopyMode = False
Selection.Copy
Columns("F:F").Paste
Application.CutCopyMode = False
Columns("N:N").Select
Application.CutCopyMode = False
Selection.Copy
Columns("G:G").Paste
Application.CutCopyMode = False
Columns("J:J").Select
Application.CutCopyMode = False
Selection.Copy
Columns("H:H").Paste
Application.CutCopyMode = False
' Simplification contenu vierge
Sheets.Add After:=Sheets(Sheets.Count)
Sheets("vierge").Select
ActiveSheet.Range("$A$1:$O$10000").AutoFilter Field:=1, Criteria1:="<>"
Range("A1:O10000").Copy
Sheets("Feuil1").Range("A1").Paste
Application.CutCopyMode = False
Sheets("vierge").Delete
Sheets("Feuil1").Name = "vierge"
' Copie dans vierge des commentaires de la semaine précédente par reconnaissance du numéro de la FS
Range("E2").FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-4],'FS_semaine N'!R2C1:R1000C15,5,FALSE)),""NEW / à éclaircir"",VLOOKUP(RC[-4],'FS_semaine N'!R2C1:R1000C15,5,FALSE))"
Range("E2").AutoFill Destination:=Range("E2:E1000"), Type:=xlFillDefault
Columns("E:E").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
' Copie dans vierge du Type de Réseau par reconnaissance du numéro de FS
Range("I2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-8],'FS_semaine N'!R2C1:R1000C11,9,FALSE)),""NEW / à classer"",VLOOKUP(RC[-8],'FS_semaine N'!R2C1:R1000C11,9,FALSE))"
Range("I2").Select
Selection.AutoFill Destination:=Range("I2:I1000"), Type:=xlFillDefault
Columns("I:I").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
' Copie dans vierge de la Date prochain Réseau par reconnaissance de FS
Range("J2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-9],'FS_semaine N'!R2C1:R1000C11,10,FALSE)),""NEW / à programmer"",VLOOKUP(RC[-9],'FS_semaine N'!R2C1:R1000C11,10,FALSE))"
Range("J2").Select
Selection.AutoFill Destination:=Range("J2:J1000"), Type:=xlFillDefault
Columns("J:J").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
' Copie dans vierge du Nom Acheteur par reconnaissance de FS
Range("K2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-10],'FS_semaine N'!R2C1:R1000C15,11,FALSE)),"""",VLOOKUP(RC[-10],'FS_semaine N'!R2C1:R1000C15,11,FALSE))"
Range("K2").Select
Selection.AutoFill Destination:=Range("K2:K1000"), Type:=xlFillDefault
Columns("K:K").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
' Copie des Filtres GCO etc par reconaissance de FS
Range("L2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-11],'FS_semaine N'!R2C1:R1000C16,12,FALSE)),"""",VLOOKUP(RC[-11],'FS_semaine N'!R2C1:R1000C16,12,FALSE))"
Range("L2").Select
Selection.AutoFill Destination:=Range("L2:L1000"), Type:=xlFillDefault
Columns("L:L").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
' Copie Filtre PCM
Range("M2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-12],'FS_semaine N'!R2C1:R1000C16,13,FALSE)),"""",VLOOKUP(RC[-12],'FS_semaine N'!R2C1:R1000C16,13,FALSE))"
Range("M2").Select
Selection.AutoFill Destination:=Range("M2:M1000"), Type:=xlFillDefault
Columns("M:M").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
' Copie Filtre New RCO
Range("N2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-13],'FS_semaine N'!R2C1:R1000C16,14,FALSE)),"""",VLOOKUP(RC[-13],'FS_semaine N'!R2C1:R1000C16,14,FALSE))"
Range("N2").Select
Selection.AutoFill Destination:=Range("N2:N1000"), Type:=xlFillDefault
Columns("N:N").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
' Copie Filtre Transfert
Range("O2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-14],'FS_semaine N'!R2C1:R1000C16,15,FALSE)),"""",VLOOKUP(RC[-14],'FS_semaine N'!R2C1:R1000C16,15,FALSE))"
Range("O2").Select
Selection.AutoFill Destination:=Range("O2:O1000"), Type:=xlFillDefault
Columns("O:O").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
' Identification dans Semaine N des FS absentes du nouvel export
Sheets("FS_semaine N").Select
Range("F2").Select
ActiveCell.FormulaR1C1 = _
"=IF(OR(ISBLANK(RC[-5]),ISERROR(VLOOKUP(RC[-5],vierge!R2C1:R1000C9,6,FALSE))),""soldé ou abandonné"",VLOOKUP(RC[-5],vierge!R2C1:R1000C9,6,FALSE))"
Range("G2").Select
ActiveCell.FormulaR1C1 = _
"=IF(OR(ISBLANK(RC[-6]),ISERROR(VLOOKUP(RC[-6],vierge!R2C1:R1000C9,7,FALSE))),""soldé ou abandonné"",VLOOKUP(RC[-6],vierge!R2C1:R1000C9,7,FALSE))"
Range("F2:G2").Select
Selection.AutoFill Destination:=Range("F2:G1000"), Type:=xlFillDefault
Range("F2:G1000").Select
Columns("F:F").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Columns("G:G").Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("F2").Select
Sheets("vierge").Select
Columns("P:BJ").Select
Range("BJ1").Activate
Selection.Delete Shift:=xlToLeft
Range("O1").Select
' Application de Modèle sur onglet vierge
Sheets("Modèle").Select
Cells.Select
Selection.Copy
Sheets("vierge").Select
Cells.Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Sheets("Modèle").Select
Rows("1:1").Select
Selection.Copy
Sheets("vierge").Select
Rows("1:1").Select
ActiveSheet.Paste
' Décalage des onglets N-1 => N + création onglet vierge
Sheets("FS_semaine N-1").Select
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.Delete
Sheets("FS_semaine N").Select
Sheets("FS_semaine N").Name = "FS_semaine N-1"
Rows("1:1").Select
Selection.AutoFilter
Sheets("vierge").Select
Sheets("vierge").Name = "FS_semaine N"
Sheets.Add After:=Sheets(Sheets.Count)
Sheets("Feuil2").Select
Sheets("Feuil2").Name = "vierge"
Sheets("FS_semaine N").Select
Rows("1:1").Select
Selection.AutoFilter
' Copie des Noms acheteur + GCO + PCM + J3J4 + UT par reconnaissance FS en N-1
Range("K2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-10],'FS_semaine N-1'!R2C1:R1000C12,11,FALSE)),"""",VLOOKUP(RC[-10],'FS_semaine N-1'!R2C1:R1000C12,11,FALSE))"
Range("K2").Select
Selection.AutoFill Destination:=Range("K2:K1000"), Type:=xlFillDefault
Range("K2:K1000").Select
Columns("K:K").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("L2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-11],'FS_semaine N-1'!R2C1:R1000C12,12,FALSE)),"""",VLOOKUP(RC[-11],'FS_semaine N-1'!R2C1:R1000C12,12,FALSE))"
Range("L2").Select
Selection.AutoFill Destination:=Range("L2:L1000"), Type:=xlFillDefault
Range("L2:L1000").Select
Columns("L:L").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("M2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-12],'FS_semaine N-1'!R2C1:R1000C15,13,FALSE)),"""",VLOOKUP(RC[-12],'FS_semaine N-1'!R2C1:R1000C15,13,FALSE))"
Range("M2").Select
Selection.AutoFill Destination:=Range("M2:M1000"), Type:=xlFillDefault
Range("M2:M1000").Select
Columns("M:M").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("N2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-13],'FS_semaine N-1'!R2C1:R1000C15,14,FALSE)),"""",VLOOKUP(RC[-13],'FS_semaine N-1'!R2C1:R1000C15,14,FALSE))"
Range("N2").Select
Selection.AutoFill Destination:=Range("N2:N1000"), Type:=xlFillDefault
Range("N2:N1000").Select
Columns("N:N").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("O2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-14],'FS_semaine N-1'!R2C1:R1000C15,15,FALSE)),"""",VLOOKUP(RC[-14],'FS_semaine N-1'!R2C1:R1000C15,15,FALSE))"
Range("O2").Select
Selection.AutoFill Destination:=Range("O2:O1000"), Type:=xlFillDefault
Range("O2:O1000").Select
Columns("O:O").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
' Application Menus Déroulants sur Date Réseau RCO et Type Réseau
Range("J2:J1000").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:= _
"=Modèle!$J$2:$J$31"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Range("I2:I1000").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=Modèle!$I$2:$I$6"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
' Application Menus Déroulants sur Acheteur OCM New RCO Transfert
Range("K2:K1000").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=Modèle!$H$2:$H$110"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Range("M2:M1000").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=Modèle!$E$2:$E$8"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Range("N2:N1000").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=Modèle!$D$2:$D$15"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
' Mise en forme visuel Semaine N
Range("D2").Select
ActiveWindow.Zoom = 80
With ActiveWindow
.SplitColumn = 4
.SplitRow = 1
End With
ActiveWindow.SplitColumn = 0
ActiveWindow.SplitRow = 2
ActiveWindow.SplitRow = 1
ActiveWindow.FreezePanes = True
Range("E2").Select
' Mise à jour de l'onglet Accueil
Sheets("Accueil").Select
Range("M5").Select
ActiveCell.FormulaR1C1 = _
"=COUNTIF('FS_semaine N'!R1C10:R997C10,Accueil!R[-1]C)"
Range("M5").Select
Selection.Copy
Range("N5:S5").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range("M7").Select
ActiveCell.FormulaR1C1 = _
"=COUNTIFS('FS_semaine N'!R1C10:R997C10,Accueil!R[-3]C,'FS_semaine N'!R1C3:R997C3,""PEPP DV"")"
Range("M7").Select
Selection.Copy
Range("N7:S7").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("M9").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = _
"=COUNTIFS('FS_semaine N'!R1C10:R997C10,Accueil!R[-5]C,'FS_semaine N'!R1C3:R997C3,""PEPP DW"")"
Range("M9").Select
Selection.Copy
Range("N9:S9").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("M11").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = _
"=COUNTIFS('FS_semaine N'!R1C10:R997C10,Accueil!R[-7]C,'FS_semaine N'!R1C3:R997C3,""PEPP VSUD Transversal"")"
Range("M11").Select
Selection.Copy
Range("N11:S11").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("M13").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = _
"=COUNTIFS('FS_semaine N'!R3C10:R999C10,Accueil!R[-9]C,'FS_semaine N'!R3C3:R999C3,""PEPP DT-PUMA"")"
Range("M13").Select
Selection.Copy
Range("N13:S13").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
ActiveWindow.LargeScroll Down:=-1
Range("M5").Select
End Sub
J'ai commencé par réduire les selects
un erreur parait toujours je sais pas pourquoi
merci si vous pouvez me proposer des optimisations du code
Sub Macro1()
'
' Macro1 Macro
'
' Sub Miseàjour()
'
' Miseàjour Macro
'
' Suppression Filtre
Sheets("FS_semaine N").Select
Rows("1:1").Select
Selection.AutoFilter
' Arrangement onglet vierge (ordre croissant et colonnes rangées)
Sheets("vierge").Select
Cells.Select
' Selection.Columns.Ungroup
Columns("A:CJ").Select
Selection.EntireColumn.Hidden = False
Rows("1:7").Delete Shift:=xlUp
Cells.Select
With Selection
.WrapText = True
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("Y2").FormulaR1C1 = _
"=IF(ISBLANK(R[1]C[-10]),CONCATENATE(RC[-1],"" "",R[1]C[-1]),RC[-1])"
Range("Y2").AutoFill Destination:=Range("Y2:Y10000"), Type:=xlFillDefault
Columns("Y:Y").Copy
Columns("Y:Y").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Columns("Y:Y").Select
Application.CutCopyMode = False
Selection.Copy
Columns("X:X").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("AB2").FormulaR1C1 = _
"=IF(RC[-1]=""INITIALIZATION"",RC[3],IF(RC[-1]=""INSTRUCTION"",RC[5],IF(RC[-1]=""DEVELOPMENT"",RC[7],IF(RC[-1]=""OFFICIALIZATION - INDUSTRIALIZATION"",RC[9],RC[10]))))"
Range("AB2").AutoFill Destination:=Range("AB2:AB10000"), Type:=xlFillDefault
Columns("AB:AB").Copy
Columns("AB:AB").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Columns("AB:AB").Select
Application.CutCopyMode = False
Rows("1:1").Select
ActiveWindow.LargeScroll ToRight:=2
Columns("A:N").Select
Range("N1").Delete Shift:=xlToLeft
Columns("B:B").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("B2").FormulaR1C1 = "=IF(VALUE(RC[-1])=0,"""",VALUE(RC[-1]))"
Range("B2").AutoFill Destination:=Range("B2:B10000"), Type:=xlFillDefault
Columns("B:B").Copy
Columns("B:B").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Columns("A:A").Select
Range("A1").Delete Shift:=xlToLeft
ActiveWorkbook.Worksheets("vierge").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("vierge").AutoFilter.Sort.SortFields.Add Key:=Range _
("A1"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("vierge").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Rows("1:1").AutoFilter
Columns("E:E").Copy
Columns("B:B").Paste
Columns("I:I").Select
Application.CutCopyMode = False
Selection.Copy
Columns("D").Paste
Columns("F:F").Select
Application.CutCopyMode = False
Selection.Copy
Columns("C:C").Paste
Application.CutCopyMode = False
Columns("M:M").Select
Application.CutCopyMode = False
Selection.Copy
Columns("F:F").Paste
Application.CutCopyMode = False
Columns("N:N").Select
Application.CutCopyMode = False
Selection.Copy
Columns("G:G").Paste
Application.CutCopyMode = False
Columns("J:J").Select
Application.CutCopyMode = False
Selection.Copy
Columns("H:H").Paste
Application.CutCopyMode = False
' Simplification contenu vierge
Sheets.Add After:=Sheets(Sheets.Count)
Sheets("vierge").Select
ActiveSheet.Range("$A$1:$O$10000").AutoFilter Field:=1, Criteria1:="<>"
Range("A1:O10000").Copy
Sheets("Feuil1").Range("A1").Paste
Application.CutCopyMode = False
Sheets("vierge").Delete
Sheets("Feuil1").Name = "vierge"
' Copie dans vierge des commentaires de la semaine précédente par reconnaissance du numéro de la FS
Range("E2").FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-4],'FS_semaine N'!R2C1:R1000C15,5,FALSE)),""NEW / à éclaircir"",VLOOKUP(RC[-4],'FS_semaine N'!R2C1:R1000C15,5,FALSE))"
Range("E2").AutoFill Destination:=Range("E2:E1000"), Type:=xlFillDefault
Columns("E:E").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
' Copie dans vierge du Type de Réseau par reconnaissance du numéro de FS
Range("I2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-8],'FS_semaine N'!R2C1:R1000C11,9,FALSE)),""NEW / à classer"",VLOOKUP(RC[-8],'FS_semaine N'!R2C1:R1000C11,9,FALSE))"
Range("I2").Select
Selection.AutoFill Destination:=Range("I2:I1000"), Type:=xlFillDefault
Columns("I:I").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
' Copie dans vierge de la Date prochain Réseau par reconnaissance de FS
Range("J2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-9],'FS_semaine N'!R2C1:R1000C11,10,FALSE)),""NEW / à programmer"",VLOOKUP(RC[-9],'FS_semaine N'!R2C1:R1000C11,10,FALSE))"
Range("J2").Select
Selection.AutoFill Destination:=Range("J2:J1000"), Type:=xlFillDefault
Columns("J:J").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
' Copie dans vierge du Nom Acheteur par reconnaissance de FS
Range("K2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-10],'FS_semaine N'!R2C1:R1000C15,11,FALSE)),"""",VLOOKUP(RC[-10],'FS_semaine N'!R2C1:R1000C15,11,FALSE))"
Range("K2").Select
Selection.AutoFill Destination:=Range("K2:K1000"), Type:=xlFillDefault
Columns("K:K").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
' Copie des Filtres GCO etc par reconaissance de FS
Range("L2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-11],'FS_semaine N'!R2C1:R1000C16,12,FALSE)),"""",VLOOKUP(RC[-11],'FS_semaine N'!R2C1:R1000C16,12,FALSE))"
Range("L2").Select
Selection.AutoFill Destination:=Range("L2:L1000"), Type:=xlFillDefault
Columns("L:L").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
' Copie Filtre PCM
Range("M2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-12],'FS_semaine N'!R2C1:R1000C16,13,FALSE)),"""",VLOOKUP(RC[-12],'FS_semaine N'!R2C1:R1000C16,13,FALSE))"
Range("M2").Select
Selection.AutoFill Destination:=Range("M2:M1000"), Type:=xlFillDefault
Columns("M:M").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
' Copie Filtre New RCO
Range("N2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-13],'FS_semaine N'!R2C1:R1000C16,14,FALSE)),"""",VLOOKUP(RC[-13],'FS_semaine N'!R2C1:R1000C16,14,FALSE))"
Range("N2").Select
Selection.AutoFill Destination:=Range("N2:N1000"), Type:=xlFillDefault
Columns("N:N").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
' Copie Filtre Transfert
Range("O2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-14],'FS_semaine N'!R2C1:R1000C16,15,FALSE)),"""",VLOOKUP(RC[-14],'FS_semaine N'!R2C1:R1000C16,15,FALSE))"
Range("O2").Select
Selection.AutoFill Destination:=Range("O2:O1000"), Type:=xlFillDefault
Columns("O:O").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
' Identification dans Semaine N des FS absentes du nouvel export
Sheets("FS_semaine N").Select
Range("F2").Select
ActiveCell.FormulaR1C1 = _
"=IF(OR(ISBLANK(RC[-5]),ISERROR(VLOOKUP(RC[-5],vierge!R2C1:R1000C9,6,FALSE))),""soldé ou abandonné"",VLOOKUP(RC[-5],vierge!R2C1:R1000C9,6,FALSE))"
Range("G2").Select
ActiveCell.FormulaR1C1 = _
"=IF(OR(ISBLANK(RC[-6]),ISERROR(VLOOKUP(RC[-6],vierge!R2C1:R1000C9,7,FALSE))),""soldé ou abandonné"",VLOOKUP(RC[-6],vierge!R2C1:R1000C9,7,FALSE))"
Range("F2:G2").Select
Selection.AutoFill Destination:=Range("F2:G1000"), Type:=xlFillDefault
Range("F2:G1000").Select
Columns("F:F").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Columns("G:G").Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("F2").Select
Sheets("vierge").Select
Columns("P:BJ").Select
Range("BJ1").Activate
Selection.Delete Shift:=xlToLeft
Range("O1").Select
' Application de Modèle sur onglet vierge
Sheets("Modèle").Select
Cells.Select
Selection.Copy
Sheets("vierge").Select
Cells.Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Sheets("Modèle").Select
Rows("1:1").Select
Selection.Copy
Sheets("vierge").Select
Rows("1:1").Select
ActiveSheet.Paste
' Décalage des onglets N-1 => N + création onglet vierge
Sheets("FS_semaine N-1").Select
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.Delete
Sheets("FS_semaine N").Select
Sheets("FS_semaine N").Name = "FS_semaine N-1"
Rows("1:1").Select
Selection.AutoFilter
Sheets("vierge").Select
Sheets("vierge").Name = "FS_semaine N"
Sheets.Add After:=Sheets(Sheets.Count)
Sheets("Feuil2").Select
Sheets("Feuil2").Name = "vierge"
Sheets("FS_semaine N").Select
Rows("1:1").Select
Selection.AutoFilter
' Copie des Noms acheteur + GCO + PCM + J3J4 + UT par reconnaissance FS en N-1
Range("K2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-10],'FS_semaine N-1'!R2C1:R1000C12,11,FALSE)),"""",VLOOKUP(RC[-10],'FS_semaine N-1'!R2C1:R1000C12,11,FALSE))"
Range("K2").Select
Selection.AutoFill Destination:=Range("K2:K1000"), Type:=xlFillDefault
Range("K2:K1000").Select
Columns("K:K").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("L2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-11],'FS_semaine N-1'!R2C1:R1000C12,12,FALSE)),"""",VLOOKUP(RC[-11],'FS_semaine N-1'!R2C1:R1000C12,12,FALSE))"
Range("L2").Select
Selection.AutoFill Destination:=Range("L2:L1000"), Type:=xlFillDefault
Range("L2:L1000").Select
Columns("L:L").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("M2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-12],'FS_semaine N-1'!R2C1:R1000C15,13,FALSE)),"""",VLOOKUP(RC[-12],'FS_semaine N-1'!R2C1:R1000C15,13,FALSE))"
Range("M2").Select
Selection.AutoFill Destination:=Range("M2:M1000"), Type:=xlFillDefault
Range("M2:M1000").Select
Columns("M:M").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("N2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-13],'FS_semaine N-1'!R2C1:R1000C15,14,FALSE)),"""",VLOOKUP(RC[-13],'FS_semaine N-1'!R2C1:R1000C15,14,FALSE))"
Range("N2").Select
Selection.AutoFill Destination:=Range("N2:N1000"), Type:=xlFillDefault
Range("N2:N1000").Select
Columns("N:N").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("O2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-14],'FS_semaine N-1'!R2C1:R1000C15,15,FALSE)),"""",VLOOKUP(RC[-14],'FS_semaine N-1'!R2C1:R1000C15,15,FALSE))"
Range("O2").Select
Selection.AutoFill Destination:=Range("O2:O1000"), Type:=xlFillDefault
Range("O2:O1000").Select
Columns("O:O").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
' Application Menus Déroulants sur Date Réseau RCO et Type Réseau
Range("J2:J1000").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:= _
"=Modèle!$J$2:$J$31"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Range("I2:I1000").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=Modèle!$I$2:$I$6"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
' Application Menus Déroulants sur Acheteur OCM New RCO Transfert
Range("K2:K1000").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=Modèle!$H$2:$H$110"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Range("M2:M1000").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=Modèle!$E$2:$E$8"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Range("N2:N1000").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=Modèle!$D$2:$D$15"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
' Mise en forme visuel Semaine N
Range("D2").Select
ActiveWindow.Zoom = 80
With ActiveWindow
.SplitColumn = 4
.SplitRow = 1
End With
ActiveWindow.SplitColumn = 0
ActiveWindow.SplitRow = 2
ActiveWindow.SplitRow = 1
ActiveWindow.FreezePanes = True
Range("E2").Select
' Mise à jour de l'onglet Accueil
Sheets("Accueil").Select
Range("M5").Select
ActiveCell.FormulaR1C1 = _
"=COUNTIF('FS_semaine N'!R1C10:R997C10,Accueil!R[-1]C)"
Range("M5").Select
Selection.Copy
Range("N5:S5").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range("M7").Select
ActiveCell.FormulaR1C1 = _
"=COUNTIFS('FS_semaine N'!R1C10:R997C10,Accueil!R[-3]C,'FS_semaine N'!R1C3:R997C3,""PEPP DV"")"
Range("M7").Select
Selection.Copy
Range("N7:S7").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("M9").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = _
"=COUNTIFS('FS_semaine N'!R1C10:R997C10,Accueil!R[-5]C,'FS_semaine N'!R1C3:R997C3,""PEPP DW"")"
Range("M9").Select
Selection.Copy
Range("N9:S9").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("M11").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = _
"=COUNTIFS('FS_semaine N'!R1C10:R997C10,Accueil!R[-7]C,'FS_semaine N'!R1C3:R997C3,""PEPP VSUD Transversal"")"
Range("M11").Select
Selection.Copy
Range("N11:S11").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("M13").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = _
"=COUNTIFS('FS_semaine N'!R3C10:R999C10,Accueil!R[-9]C,'FS_semaine N'!R3C3:R999C3,""PEPP DT-PUMA"")"
Range("M13").Select
Selection.Copy
Range("N13:S13").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
ActiveWindow.LargeScroll Down:=-1
Range("M5").Select
End Sub