ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating a new worksheet (https://www.excelbanter.com/excel-programming/437954-creating-new-worksheet.html)

JasonK[_3_]

Creating a new worksheet
 
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



Gord Dibben

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


Gord Dibben MS Excel MVP

On Sun, 03 Jan 2010 11:44:15 -0800, JasonK wrote:

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



OssieMac

Creating a new worksheet
 
Just for interest you can also add the sheet and name it in one line.

ActiveWorkbook.Worksheets.Add.Name = shtName

--
Regards,

OssieMac


"Gord Dibben" wrote:

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


Gord Dibben MS Excel MVP

On Sun, 03 Jan 2010 11:44:15 -0800, JasonK wrote:

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


.


JasonK[_3_]

Creating a new worksheet
 
Thanks OssieMac --

On Sun, 3 Jan 2010 13:29:01 -0800, OssieMac
wrote:

Just for interest you can also add the sheet and name it in one line.

ActiveWorkbook.Worksheets.Add.Name = shtName



JasonK[_3_]

Creating a new worksheet
 
Thanks Gord -- worked perfectly


On Sun, 03 Jan 2010 12:27:27 -0800, Gord Dibben <gorddibbATshawDOTca
wrote:

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


Gord Dibben MS Excel MVP

On Sun, 03 Jan 2010 11:44:15 -0800, JasonK wrote:

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



Gord Dibben

Creating a new worksheet
 
Good point.

Thanks, Gord

On Sun, 3 Jan 2010 13:29:01 -0800, OssieMac
wrote:

Just for interest you can also add the sheet and name it in one line.

ActiveWorkbook.Worksheets.Add.Name = shtName




All times are GMT +1. The time now is 10:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com