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
| Private Sub CommandButton9_Click()
Dim Nom As String, i As Byte, Verif As Boolean, myMonth As Integer, myYear As Integer, myDate As Date, ee As String, a As Long
myDate = Date ' enregistre la date d'aujourd'hui dans la variable myDate
myMonth = (Month(myDate)) ' No du mois précédent
myYear = Year(Date) 'No année
ee = ""
recom:
Verif = False
Nom = InputBox("Définissez le nom du nouveau svp", "Ajout nouveau ") & "" & (myMonth) & " - " & myYear
If Nom = "" Then Exit Sub
With Workbooks("AVIONS")
For i = 1 To .Worksheets.Count
If .Sheets(i).Name = Nom Then
Verif = True
Exit For
End If
Next i
End With
If Verif = True Then
MsgBox "la feuille " & Nom & " existe déjà, veuillez choisir un autre nom"
GoTo recom
End If
Workbooks("AVIONS").Sheets.Add(After:=Sheets(Sheets.Count)).Name = Nom
Application.ScreenUpdating = False
Workbooks("AVIONS").Sheets(1).Activate
Range("A1:P3").Select
Selection.Copy
Workbooks("AVIONS").Sheets(Nom).Activate
Range("A1").Select
ActiveSheet.Paste
'On copie colle uniquement le format des colonnes
Workbooks("AVIONS").Sheets(1).Activate
Columns("A:P").Select
Selection.Copy
Workbooks("AVIONS").Sheets(Nom).Activate
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.ScreenUpdating = True
Unload Me
UserForm1.Show
End Sub |
Partager