Hi everyone,
this is the code I used to create a command button that copy a sheet and its code in the same woorkbook. It also rename it:
I want to copy the worksheet("COPRA"

and rename it.
In this code, Reponse means answer in french, so worksheet(Reponse) is the name you give to the saved sheet;
If you want to use this code, just change worksheet("COPRA"

by the name of the worksheet you want to save.
Sorry about my english if there are some mistake, I am French
![[medal] [medal] [medal]](/data/assets/smilies/medal.gif)
and I need some coffee by now!!!
Private Sub CommandButton3_Click()
Dim Sh As Worksheet
Dim Reponse As String
Dim MonNom As String
Dim BonNom As Boolean
Dim Code$, NextLine&
Dim LeString
LeString = ":\/?*[]"
Do
BonNom = True
Reponse = InputBox("Please enter a name" _
+ vbCrLf + "for the new sheet:", _
"Give a name to the sheet", MonNom)
If Reponse <> "" Then
'check if the name already exist
For a = 1 To ActiveWorkbook.Worksheets.Count
If UCase(Reponse) = UCase(Worksheets(a).Name) Then
supp = MsgBox( _
"This sheet already exist," _
+ vbCrLf + vbCrLf + _
"Do you want to change it?.", vbYesNo + vbOKOnly, _
"Name already exist"

If supp = vbYes Then
Application.DisplayAlerts = False
'Save the informations on the sheet before erasing it
ActiveSheet.Select
ActiveSheet.Cells.Select
Application.Selection.Copy
Worksheets("COPRA"

.Activate
Worksheets("COPRA"

.Paste
ActiveSheet.Range("A1"

.Select
Worksheets(Reponse).Delete
Exit For
Else
BonNom = False
MonNom = Reponse
Exit For
End If
End If
Next
'Check that the number of letters used in the name is under 31 (because this is the limit of Excel)...
If Len(Reponse) > 31 Then
MsgBox "The number of letters(" & _
Len(Reponse) & "

used in your name is" _
+ vbCrLf + " over the one allowed by Excel.", _
vbCritical + vbInformation, "Name too long"
BonNom = False
MonNom = Reponse
End If
'Check if you used wrong letters
For a = 1 To Len(LeString)
If InStr(1, Reponse, Mid(LeString, a, 1), vbTextCompare) > 0 Then
MsgBox "The letters: " & _
LeString & " are forbiden" _
+ vbCrLf + "in the name of a worksheet.", _
vbCritical + vbOKOnly, "Letters forbiden"
BonNom = False
MonNom = Reponse
Exit For
End If
Next
Else
Exit Sub
End If
Loop Until BonNom = True
'Copy the worksheet("COPRA"

and rename it
Worksheets("COPRA"

.Copy after:=Worksheets("COPRA"

Set Sh = Worksheets("COPRA (2)"

Sh.Name = Reponse
ActiveSheet.Range("A1"

.Select
End Sub
I hope this will help many people!!!!
AirChris