ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   HowTo add and name 2 wks to wkbk (https://www.excelbanter.com/excel-programming/324656-howto-add-name-2-wks-wkbk.html)

dan

HowTo add and name 2 wks to wkbk
 
How do I add and name 2 new worksheets to my workbook? I
had previously deleted a worksheet and thought that the
new sheet would be sheet1 but my code error because new
sheet was sheet2. I want to add 2 sheets called "Final"
and "ScrubData".

I had:
Sub InsertWorksheets()
Dim i As Integer

i=Sheet.Count+1

' I error out here
Sheets(i).Add
ActiveSheets.Select
ActiveSheet.Name="Final"

....confused.
Can someone help this newbie? Thanks.




Bob Phillips[_6_]

HowTo add and name 2 wks to wkbk
 
Worksheets.Add.Name = "Final"
Worksheets.Add.Name = "ScrubData"

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Dan" wrote in message
...
How do I add and name 2 new worksheets to my workbook? I
had previously deleted a worksheet and thought that the
new sheet would be sheet1 but my code error because new
sheet was sheet2. I want to add 2 sheets called "Final"
and "ScrubData".

I had:
Sub InsertWorksheets()
Dim i As Integer

i=Sheet.Count+1

' I error out here
Sheets(i).Add
ActiveSheets.Select
ActiveSheet.Name="Final"

...confused.
Can someone help this newbie? Thanks.






Tom Ogilvy

HowTo add and name 2 wks to wkbk
 
worksheets.Add(After:=Worksheets( _
Worksheets.count)).Name = "Final"
worksheets.Add(After:=Worksheets( _
Worksheets.count)).Name = "ScrubData"

--
Regards,
Tom Ogilvy

"Dan" wrote in message
...
How do I add and name 2 new worksheets to my workbook? I
had previously deleted a worksheet and thought that the
new sheet would be sheet1 but my code error because new
sheet was sheet2. I want to add 2 sheets called "Final"
and "ScrubData".

I had:
Sub InsertWorksheets()
Dim i As Integer

i=Sheet.Count+1

' I error out here
Sheets(i).Add
ActiveSheets.Select
ActiveSheet.Name="Final"

...confused.
Can someone help this newbie? Thanks.







All times are GMT +1. The time now is 02:14 AM.

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