Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Add new sheets with code

Option Explicit
Sub testme()
Dim NewSheets As Variant
Dim i As Long

NewSheets = Array("AllVolunteers", "Roofing", "Sidings")
For i = LBound(NewSheets) To UBound(NewSheets)
Sheets.Add after:=Sheets(1)
ActiveSheet.Name = NewSheets(i)
Next i
End Sub

You may want to change this:
For i = LBound(NewSheets) To UBound(NewSheets)
to
For i = uBound(NewSheets) To lBound(NewSheets) step -1

if the order of the new worksheets is important.

Linda wrote:

OOps I'm all set, please disregard my last e-mail. One other question
though, how do I add these after my Sheet one, these are placed before my
first sheet.

"Toppers" wrote:

Something like:

newsheets = Array("AllVolunteers", "Roofing", "Sidings")
For i = 1 To 3
Sheets.Add
ActiveSheet.Name = newsheets(i - 1)
Next i

HTH

"Linda" wrote:

I want to add additional sheets to my workbook with VBA. My workbook is
titled Habitat and I want to add the sheets titled "AllVolunteers",
"Roofing", "Siding". I have many more to add but if you can help me with
these, that would be great. I looked at my recorded macro code, but it isn't
working when I try to run it. Thank you


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code in certain sheets MAX Excel Worksheet Functions 1 February 6th 10 09:27 PM
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? Dmitry Excel Worksheet Functions 6 March 29th 06 12:43 PM
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? Dmitry Excel Programming 6 March 29th 06 12:43 PM
run code on opening workbook and apply code to certain sheets Jane Excel Programming 7 August 8th 05 09:15 AM
Same code in several sheets.. Soniya Excel Programming 1 September 11th 03 07:50 AM


All times are GMT +1. The time now is 12:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"