Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default a quick way of inserting and naming multiple worksheets in Excel?

We have to insert 20 worksheets that each have a different name into an
existing Excel Workbook - is there a quick way of doing this?

Please help if you can

Sue
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,203
Default a quick way of inserting and naming multiple worksheets in Excel?

This code should work for you, it inserts 20 sheets at the end of the active
workbook and gives them names you define. To use the code, open the workbook
and press [Alt]+[F11] to open the VB Editor. Choose Insert -- Module and
copy and paste the code into it, change the worksheet names to whatever you
want them to be (cannot be the name of an existing sheet in the book). Close
the VB Editor and use Tools -- Macro -- Macros and run the macro. Actually
you could just press [F5] while in the VB Editor with the cursor inside of
the code and then just delete the code once you're done with it.

Here's that code, more to follow:
Sub Add20Sheets()
'Adds and renames 20 sheets at the end
'of the workbook
'set up names for the new sheets
Dim newNames(1 To 20) As String
Dim LC As Integer ' loop counter

'change these as required
newNames(1) = "NewSheet#1"
newNames(2) = "NewSheet#2"
newNames(3) = "NewSheet#3"
newNames(4) = "NewSheet#4"
newNames(5) = "NewSheet#5"
newNames(6) = "NewSheet#6"
newNames(7) = "NewSheet#7"
newNames(8) = "NewSheet#8"
newNames(9) = "NewSheet#9"
newNames(10) = "NewSheet#10"
newNames(11) = "NewSheet#11"
newNames(12) = "NewSheet#12"
newNames(13) = "NewSheet#13"
newNames(14) = "NewSheet#14"
newNames(15) = "NewSheet#15"
newNames(16) = "NewSheet#16"
newNames(17) = "NewSheet#17"
newNames(18) = "NewSheet#18"
newNames(19) = "NewSheet#19"
newNames(20) = "NewSheet#20"
'we loop based on the size of the
'newNames() array, so you can change
'that to modify this to work to add
'different number of worksheets
'in the future
Application.ScreenUpdating = False ' speed things up
For LC = LBound(newNames) To UBound(newNames)
Sheets.Add after:=Worksheets(Worksheets.Count)
ActiveSheet.Name = newNames(LC)
Next
End Sub

If you just want to add 20 sheets and let Excel give them names, use this
code instead:

Sub Add20Sheets()
'Adds 20 sheets at the end
'of the workbook
Application.ScreenUpdating = False ' speed things up
For LC = 1 To 20
Sheets.Add after:=Worksheets(Worksheets.Count)
Next
End Sub


"Sue" wrote:

We have to insert 20 worksheets that each have a different name into an
existing Excel Workbook - is there a quick way of doing this?

Please help if you can

Sue

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,203
Default a quick way of inserting and naming multiple worksheets in Excel?

Oops, cut too much away from the 2nd macro: use this instead for the "just
20 sheets" solution:

Sub Add20Sheets()
'Adds 20 sheets at the end
'of the workbook
Dim LC As Integer
Application.ScreenUpdating = False ' speed things up
For LC = 1 To 20
Sheets.Add after:=Worksheets(Worksheets.Count)
Next
End Sub


"Sue" wrote:

We have to insert 20 worksheets that each have a different name into an
existing Excel Workbook - is there a quick way of doing this?

Please help if you can

Sue

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 896
Default a quick way of inserting and naming multiple worksheets in Excel?

with yr new worksheet names in A1:A20 try this macro

Sub cus()

For Each cell In Selection
Worksheets.Add
ActiveSheet.Name = cell
Next cell

End Sub

On 4 Gru, 13:26, Sue <Sue @discussions.microsoft.com wrote:
We have to insert 20 worksheets that each have a different name into an
existing Excel Workbook - is there a quick way of doing this?

Please help if you can

Sue


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 896
Default a quick way of inserting and naming multiple worksheets in Excel?

forgot to add: select A1:A20

On 4 Gru, 14:04, Jarek Kujawa wrote:
with yr new worksheet names in A1:A20 try this macro

Sub cus()

For Each cell In Selection
Worksheets.Add
ActiveSheet.Name = cell
Next cell

End Sub

On 4 Gru, 13:26, Sue <Sue @discussions.microsoft.com wrote:



We have to insert 20 worksheets that each have a different name into an
existing Excel Workbook - is there a quick way of doing this?


Please help if you can


Sue- Ukryj cytowany tekst -


- Pokaż cytowany tekst -




  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default a quick way of inserting and naming multiple worksheets in Excel?

With a list of names in A1:A20 on a current sheet.

Sub Add_Sheets22()
Dim rCell As Range
For Each rCell In Range("A1:A20")
With Worksheets.Add(After:=Worksheets(Worksheets.Count) )
.Name = rCell.Value
End With
Next rCell
End Sub


Gord Dibben MS Excel MVP

On Fri, 4 Dec 2009 04:26:01 -0800, Sue <Sue @discussions.microsoft.com
wrote:

We have to insert 20 worksheets that each have a different name into an
existing Excel Workbook - is there a quick way of doing this?

Please help if you can

Sue


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
Naming ranges on multiple worksheets Jim New Users to Excel 3 November 23rd 09 09:08 PM
inserting rows on multiple worksheets roadkill Excel Worksheet Functions 0 August 17th 07 01:57 AM
Quick question on naming a union of ranges [email protected] Excel Discussion (Misc queries) 2 July 29th 07 11:15 AM
Inserting multiple worksheets Marta Excel Discussion (Misc queries) 7 November 23rd 06 09:57 PM
Adding and Naming Multiple Worksheets Byron Excel Worksheet Functions 6 September 8th 05 02:52 AM


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

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"