Creating a copy of a sheet and naming it

  • Thread starter Thread starter brian.jermain
  • Start date Start date
B

brian.jermain

Being a newbie to VBA could I please have some advice .

What I am trying to do is write a macro to select the active sheet and
create a copy of it but then I would like an input message to ask me
what to name the sheet so that I am presented with an exact copy
(including macro buttons) but with a name of my choice. I have tried a
myriad of combinations but do not seem able to get it to work

This macro must be able to work with any selected sheet in the workbook

Any help would be appreciated

Brian
Scotland
 
Brian,

SheetName = InputBox("Enter desired name for copy of active sheet")
activesheet.Copy After:=ActiveSheet
ActiveSheet.Name = SheetName

It will copy the selected sheet and put it sheet after the selected sheet.
It won't check that the name entered already exists in a sheet, which will
cause an error.

As a starter, you can start the macro recorder (Tools - Macro - Record new
macro), do the biz, stop the recorder, then modify the code as needed.
 
Earl

Thank you very much - you make it look so easy

Much appreciated

Brian
 

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

Back
Top