Macro: Copy a worksheet and rename it to a specified value

M

mitch

I've got a userform created with a textbox, an apply button and a cancel
button. If OK is clicked, i want the macro to duplicate a specific named
worksheet (say template) and rename the duplicate to the value in the textbox.

This doesn't seem to be terrible difficult, but I'm having problems. Any
advice?
 
J

Joel

OldSheet = "Sheet1"
Worksheets(OldSheet).Copy after:=Sheets(Sheets.Count)
Set Newsht = ActiveSheet
Newsht.Name = "Joel"
 
S

Shane Devenshire

Hi,

Private Sub OK_Click()
Sheets("Template").Copy After:=ActiveSheet
ActiveSheet.Name = Me.TextBox1
Unload Me
End Sub

where TextBox1 is the name of your textbox on the form. and the ok button is
named OK.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top