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
| Sub sauve_resultat()
Set WB_macro = ActiveWorkbook.ActiveSheet
CurPath = ActiveWorkbook.Path
Set Wb_bc1 = ActiveWorkbook.Sheets("Bon commande 1")
Set Wb_bc2 = ActiveWorkbook.Sheets("Bon commande 2")
Set Wb_bc3 = ActiveWorkbook.Sheets("Bon commande 3")
Set Wb_bc4 = ActiveWorkbook.Sheets("Bon commande 4")
Set Wb_bc5 = ActiveWorkbook.Sheets("Bon commande 5")
'Copie de la premiere feuille, on a au moins une livraison
Set WB_sauve = Workbooks.Add()
Wb_bc1.Copy Before:=WB_sauve.Sheets(1)
'On retire les alertes avant de supprimer les feuilles en trop
Application.DisplayAlerts = False
WB_sauve.Sheets(4).Delete
WB_sauve.Sheets(3).Delete
WB_sauve.Sheets(2).Delete
'On revient au fonctionnement normal
Application.DisplayAlerts = True
If Not (WB_macro.Cells(11, 11) = "") Then
Wb_bc2.Copy After:=WB_sauve.Sheets(WB_sauve.Sheets().Count)
End If
If Not (WB_macro.Cells(11, 13) = "") Then
Wb_bc3.Copy After:=WB_sauve.Sheets(WB_sauve.Sheets().Count)
End If
If Not (WB_macro.Cells(11, 15) = "") Then
Wb_bc4.Copy After:=WB_sauve.Sheets(WB_sauve.Sheets().Count)
End If
If Not (WB_macro.Cells(11, 17) = "") Then
Wb_bc5.Copy After:=WB_sauve.Sheets(WB_sauve.Sheets().Count)
End If
'Tous les bons de commandes ont été copiés, on va protéger les feuilles
WB_sauve.Protect "1234"
nom_fichier = CurPath & "\HIV_" & WB_macro.Cells(4, 5).Value & "_" & WB_macro.Cells(5, 5).Value
WB_sauve.SaveAs Filename:=nom_fichier
End Sub |
Partager