S
Sandy
Greetings
My code:
Private Sub CommandButton1_Click()
'
'
Dim sNewSheet As String
sNewSheet = Range("I10").Value
On Error Resume Next
If SheetExists(sNewSheet) = True Then
MsgBox "A requestRequest already exists for" & sNewSheet
Else
Sheets("template").Select
Sheets("template").Copy After:=Worksheets(Worksheets.Count)
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
ActiveSheet.Name = Range("i10").Value
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
On Error GoTo 0
End Sub
Function SheetExists(SName As String, _
Optional ByVal WB As Workbook) As Boolean
'Chip Pearson
On Error Resume Next
If WB Is Nothing Then Set WB = ThisWorkbook
SheetExists = CBool(Len(WB.Sheets(SName).Name))
End Function
What do I need to add so the button is not copied to the new sheet?
Thanks!
My code:
Private Sub CommandButton1_Click()
'
'
Dim sNewSheet As String
sNewSheet = Range("I10").Value
On Error Resume Next
If SheetExists(sNewSheet) = True Then
MsgBox "A requestRequest already exists for" & sNewSheet
Else
Sheets("template").Select
Sheets("template").Copy After:=Worksheets(Worksheets.Count)
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
ActiveSheet.Name = Range("i10").Value
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
On Error GoTo 0
End Sub
Function SheetExists(SName As String, _
Optional ByVal WB As Workbook) As Boolean
'Chip Pearson
On Error Resume Next
If WB Is Nothing Then Set WB = ThisWorkbook
SheetExists = CBool(Len(WB.Sheets(SName).Name))
End Function
What do I need to add so the button is not copied to the new sheet?
Thanks!