Sub Exportationfeuil()
Dim w As Worksheet, nom$
Set w = ActiveSheet
1 nom = InputBox("Entrez le nom de la machine", "Création d'une nouvelle feuille", nom)
If nom = "" Then Exit Sub
Application.ScreenUpdating = False
Application.DisplayAlerts = False
On Error Resume Next
With Workbooks.Open(ThisWorkbook.Path & "\Test.xlsx")
If .Name = "" Then MsgBox "Fichier 'Test.xlsx' introuvable !", 48: Exit Sub
If IsError(.Sheets(nom)) Then Else _
If MsgBox("La feuille '" & nom & "' a déjà été créée, voulez-vous la remplacer ?", 36) _
= 7 Then .Close: GoTo 1
.Sheets(nom).Delete
.Sheets.Add Before:=.Sheets(1)
.Sheets(1).Name = nom
If .Sheets(1).Name <> nom Then .Close: MsgBox "Caractère interdit !", 48: GoTo 1
w.[A:M].Copy .Sheets(1).[A1]
w.Rows("1:2").Copy .Sheets(1).[A1] 'pour la hauteur des lignes de titres
.Save
Application.ScreenUpdating = True
If MsgBox("La feuille a été créée, voulez-vous fermer ce fichier ?", 36) = 6 Then .Close
GoTo 1 'facultatif
End With
End Sub