Macro for copying sheet and naming

Firecop1348

Board Regular
Joined
Oct 24, 2009
Messages
101
I have been working on a workbook for workorders. I got it all set up but have thought about something that would save me a great amount of time.
I have a macro that makes a copy of my main workorder when clicked but the name of the new sheet is workorder (2), workorder (3) ect. . I would like to know if I could have it when I click the button to run the macro, it brings up an input box to name the new workorder sheet, then copys my orignal workorder and creates the new sheet naming it what I put into the input box. Any help would be great, everyone here has been so good to help with problems.
Thank you in advance.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Assuming that you have an ActiveX button on the sheet to be copied try

Code:
Private Sub CommandButton1_Click()
Me.Copy after:=Sheets(Sheets.Count)
ActiveSheet.Name = InputBox("Enter sheet name")
End Sub
 
Upvote 0
Im sorry, the sheet that is being copied has no active x button on it. I have a main page with a few on it. one to take me to my invatory page, one to find a workorder, and one to create a workorder from the master workorder sheet.
HTML:
Sub NewWO()
 
     Sheets("work order").Select
    Sheets("work order").Copy After:=Sheets("work order")
     Range("C9").Select
    With ActiveSheet
     .Range("E5").Value = .Name
 End With
 
End Sub
i would like this macro to work as i said earlyer, but when clicked I can input the name "bob" I want the sheet to be named and when it is created its name is " bob"
I hope this helps.
 
Upvote 0
Try

Code:
Sub NewWO()
Sheets("work order").Copy After:=Sheets("work order")
With ActiveSheet
    .Name = InputBox("Enter sheet name")
    .Range("E5").Value = .Name
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top