LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 136
Default Create Tabs from Existing Tab

Create Tabs from Existing Tab

The Last Topic was getting too long for History See
http://groups.google.com/group/micro...786c2446bdc465

With much help from Bob, I have a VB code in which I am creating new
tabs from a list and existing tab called template. The code works fine
with one exception that at the end it wants to create another tab with
the same name Template and run to an run time error for duplication of
existing tabs and creates a one called Template(2).

-------------------------------------Existing Code
Private Sub CommandButton1_Click()
' Create tabs from the list
' Bob from microsoft.public.excel.programming 11/28/2006

Dim LastCell As Range, Rng As Range, cell As Range
Dim WS As Worksheet

Set WS = ActiveSheet
Set LastCell = WS.Cells(Rows.Count, "A").End(xlUp)
Set Rng = WS.Range("A2", LastCell)

For Each cell In Rng
If Not IsEmpty(cell) Then
Sheets("Template").Copy after:=Worksheets(Worksheets.Count)
ActiveSheet.Name = cell.Value
End If
Next
End Sub
-----------------------------------------------------------------------------------

 
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
How do I sort tabs on an existing spreadsheet? IRISHBABE Excel Worksheet Functions 2 December 19th 06 02:06 AM
Create Worksheet From Values in Existing Cells Using Existing Worksheet as Template. Ardy Excel Programming 18 November 29th 06 03:23 AM
Rename all existing worksheet tabs MikeM Excel Discussion (Misc queries) 14 October 20th 06 03:29 AM
Rename existing tabs Dawn Rhoads Excel Programming 8 May 27th 05 10:00 PM
Macro Help - check existing tabs Macro Help[_2_] Excel Programming 1 July 27th 04 05:15 PM


All times are GMT +1. The time now is 06:35 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"