Duplicate worksheet creation
When I do that, I get a run time error 1004: Copy method of worksheet class
failed
What might be causing that?
"Die_Another_Day" wrote:
yes.
Double-Click your "OK" Button in the editor. This should take you to
the code for this button and should look like this:
Private Sub CommandButton1_Click()
End Sub
Add my code (without the "Sub CopySheet()" and the "End Sub") in
between the Sub End Sub for the commandbutton
HTH
Die_Another_Day
TimN wrote:
Thanks That worked!
I have a user form that asks for some key pieces of information to be
entered. Upon entry the data is placed in various cells and calculations
occur on that data.
Is there a way to make this procedure (the worksheet copy) occur when the
user clicks "OK" on the user form?
"Die_Another_Day" wrote:
Sub CopySheet()
Dim nSheet As Worksheet
Dim NameBox As String
NameBox = Application.InputBox("Please type a name for the new
worksheet", "Creating New Sheet", , , , , , 2)
If NameBox = "False" Then Exit Sub
Sheets("Sheet1").Copy Befo=Sheets(2)
Set nSheet = ActiveSheet
nSheet.Name = NameBox
End Sub
HTH
Die_Another_Day
TimN wrote:
I have read through several posts on this subject, but can't get my situation
to work.
I am trying to write code so that an exact copy of "Sheet1" is made and a
message box appears asking the user to name the new worksheet, for example
the new name might be TimNPayPeriod1.
How can I accomplish this?
Is the code entered in a new module or as part of the user form code?
Thanks for any help!
|