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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| Private Sub Archiver_Click()
Dim année As Integer
Dim mois As String
Dim archivage As String
Dim i As Integer
année = Year(Now())
mois = Format(Now(), "mmm")
archivage = "Archives" & année & ".xls"
fichier = Dir("C:\Documents and Settings\Desktop\Rapport\" & archivage)
If fichier = "" Then
Sheets("Rapport de Quart").Copy
Sheets("Rapport de Quart").Name = mois
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\Desktop\Rapport\" & archivage, _
FileFormat:=xlExcel9795, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
With Sheets(mois)
.Shapes("CommandButton1").Delete
.Shapes("CommandButton2").Delete
.Shapes("Archiver").Delete
End With
Else
If Range("C1") = "Matin" Then
i = Day(Now) - 1
Sheets("Rapport de Quart").Range("rapport").Copy
Windows("Archives" & année & ".xls").Activate
Sheets(mois).Range(Cells(1, 2 + 6 * i)).Select
Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Else
If Range("C1") = "Soir" Then
i = Day(Now) - 1
Sheets("Rapport de Quart").Range("rapport").Copy
Windows("Archives" & année & ".xls").Activate
Sheets(mois).Range(Cells(1, 4 + 6 * i)).Select
Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Else
If Range("C1").Text = "Nuit" Then
i = Day(Now) - 1
Sheets("Rapport de Quart").Range("rapport").Copy
Windows("Archives" & année & ".xls").Activate
Sheets(mois).Range(Cells(1, 6 + 6 * i)).Select
Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
End If
End If
End If
End If
End Sub |
Partager