Creating a new worksheet

  • Thread starter Thread starter JasonK
  • Start date Start date
J

JasonK

TIA boys and girls.


I need a macro that will create a worksheet titled what ever the user
wants to name it.

I would guess that means it would open a dialog box and then name the
sheet what the user writes in the box. I just can't figure out how to
do it.

Thanks for all your help,

JasonK
 
Sub newsheet()
Dim shtname as String
shtname = InputBox("Type a name")
ActiveWorkbook.Worksheets.Add
ActiveSheet.Name = shtname
End Sub


Gord Dibben MS Excel MVP
 
Just for interest you can also add the sheet and name it in one line.

ActiveWorkbook.Worksheets.Add.Name = shtName
 
Thanks Gord -- worked perfectly


Sub newsheet()
Dim shtname as String
shtname = InputBox("Type a name")
ActiveWorkbook.Worksheets.Add
ActiveSheet.Name = shtname
End Sub


Gord Dibben MS Excel MVP
 
Back
Top