change sheet name macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a large spreadsheet and I am trying to add a macro that allows me to
add a worksheet AND have an input box pop up so I can name the worksheet
whatever name I need it to be. Is this possible?
 
VERY QUICK & VERY DIRTY

Sub newsheet()
Dim ws As Worksheet
Dim nm As String

Set ws = Worksheets.Add
ws.Name = InputBox("sheet name")
End Sub
 
That is perfect, quick and dirty can work sometimes...

Now is there a way to put it in a sepecific place in the workbook?
 
Yup. The .Add method takes optional parameters of Before and/or After, so
you can specify where. In this case it is BEFORE sheet1

Sub newsheet()
Dim ws As Worksheet
Dim nm As String

Set ws = Worksheets.Add(before:=Worksheets("Sheet1"))
ws.Name = InputBox("sheet name")
End Sub
 
Okay getting there... but now is there a way to have an input box for what
sheet you would like it before?
 

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