Insert A Worksheet using VBA

M

Mike

I have a workbook that I need to add a Worksheet called "CurWorkPad" to.

Right now I can insert a worksheet and it will come up named "Sheetx", where
x=a number that increments each time a sheet is inserted. I also have code
to rename a worksheet, but it requires you to know the current name of the
inserted worksheet.

Is there a way to insert a new worksheet and rename it at the same time
without knowing what excel named the new worksheet?

Thanks for any help.
Mike
 
S

Sloth

when you insert the worksheet the new worksheet becomes selected
automatically, so you can use this to rename the new sheet

ActiveSheet.Name = "New_Name"
 
F

flow23

Try this

Sub addsheet()
Sheets.Add.Name = "CurWorkPad"
End Sub

change " curworkpad" to any name you want
 

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