ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating worksheets then name it (https://www.excelbanter.com/excel-programming/271834-creating-worksheets-then-name.html)

john

Creating worksheets then name it
 
I am attempting to create a new worksheet in a macro and
give it a specified name. I can create the worksheet with
the following command:

ActiveWorkbook.Sheets.Add After:=Worksheets("test")

What I can't figure out is how to name the newly created
worksheet.

Anyone have an idea on how to do this?

Don P

Creating worksheets then name it
 

John,

ActiveSheet.Name = "newsheet"

Don Pistulka

"john" wrote in message
...
I am attempting to create a new worksheet in a macro and
give it a specified name. I can create the worksheet with
the following command:

ActiveWorkbook.Sheets.Add After:=Worksheets("test")

What I can't figure out is how to name the newly created
worksheet.

Anyone have an idea on how to do this?




Tim Zych[_2_]

Creating worksheets then name it
 
Dim wks As Worksheet
With ActiveWorkbook
Set wks = .Sheets.Add(After:=.Sheets("test"))
End With
wks.Name = "new sheet"

"john" wrote in message
...
I am attempting to create a new worksheet in a macro and
give it a specified name. I can create the worksheet with
the following command:

ActiveWorkbook.Sheets.Add After:=Worksheets("test")

What I can't figure out is how to name the newly created
worksheet.

Anyone have an idea on how to do this?




Dana DeLouis[_5_]

Creating worksheets then name it
 
I don't think the following is shown in the documentation, but I think it
works ok...

Sub Demo()
Worksheets.Add(Befo=Sheets(1)).Name = "Test" & Sheets.Count
End Sub

--
Dana DeLouis
I am using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"john" wrote in message
...
I am attempting to create a new worksheet in a macro and
give it a specified name. I can create the worksheet with
the following command:

ActiveWorkbook.Sheets.Add After:=Worksheets("test")

What I can't figure out is how to name the newly created
worksheet.

Anyone have an idea on how to do this?





All times are GMT +1. The time now is 07:11 PM.

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