Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Use Cell Values to Create Tabs with specific names

I'd like to create a new tab for each cell in column A that has a value in it
using that cell's value as the tab name. I have a tab that the new ones
should all be copies of named "Template Tab". I'd like this to loop until it
finds a blank cell in column A and then stop.

Thanks in advance for your help!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Use Cell Values to Create Tabs with specific names

maybe something like this:

Sub test()
Dim lRow As Long
Dim sht As Worksheet
Dim shtTest As Worksheet

lRow = 1
Set sht = ActiveSheet
While sht.Range("A" & lRow).Text < ""
With sht.Range("A" & lRow)
On Error Resume Next
Set shtTest = Nothing
Set shtTest = Worksheets(.Text)
On Error GoTo 0
If shtTest Is Nothing Then
Worksheets("Template Tab").Copy After:=sht
ActiveSheet.Name = .Text
Else
Debug.Print .Text; " tab already exists"
End If
lRow = lRow + 1
End With
Wend
sht.Activate

End Sub

--
Hope that helps.

Vergel Adriano


"Mr. Matt" wrote:

I'd like to create a new tab for each cell in column A that has a value in it
using that cell's value as the tab name. I have a tab that the new ones
should all be copies of named "Template Tab". I'd like this to loop until it
finds a blank cell in column A and then stop.

Thanks in advance for your help!!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Use Cell Values to Create Tabs with specific names

Not saying that it will happen but copying worksheets has an inherent bug in
it. If you start running into an error like:
Run-time error '1004':
Copy Method of Worksheet Class failed
then check out this link for a work around...

http://support.microsoft.com/default...84&Product=xlw
--
HTH...

Jim Thomlinson


"Vergel Adriano" wrote:

maybe something like this:

Sub test()
Dim lRow As Long
Dim sht As Worksheet
Dim shtTest As Worksheet

lRow = 1
Set sht = ActiveSheet
While sht.Range("A" & lRow).Text < ""
With sht.Range("A" & lRow)
On Error Resume Next
Set shtTest = Nothing
Set shtTest = Worksheets(.Text)
On Error GoTo 0
If shtTest Is Nothing Then
Worksheets("Template Tab").Copy After:=sht
ActiveSheet.Name = .Text
Else
Debug.Print .Text; " tab already exists"
End If
lRow = lRow + 1
End With
Wend
sht.Activate

End Sub

--
Hope that helps.

Vergel Adriano


"Mr. Matt" wrote:

I'd like to create a new tab for each cell in column A that has a value in it
using that cell's value as the tab name. I have a tab that the new ones
should all be copies of named "Template Tab". I'd like this to loop until it
finds a blank cell in column A and then stop.

Thanks in advance for your help!!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Use Cell Values to Create Tabs with specific names

This is great, thanks a lot. The only thing I'd like to change is that the
last tab created be the last tab in the workbook. In other words, it would
be great if the first new tab were created at the end of all other existing
tabs and the rest of the new tabs followed that one with the final one being
last in the workbook.

Thanks again.

"Vergel Adriano" wrote:

maybe something like this:

Sub test()
Dim lRow As Long
Dim sht As Worksheet
Dim shtTest As Worksheet

lRow = 1
Set sht = ActiveSheet
While sht.Range("A" & lRow).Text < ""
With sht.Range("A" & lRow)
On Error Resume Next
Set shtTest = Nothing
Set shtTest = Worksheets(.Text)
On Error GoTo 0
If shtTest Is Nothing Then
Worksheets("Template Tab").Copy After:=sht
ActiveSheet.Name = .Text
Else
Debug.Print .Text; " tab already exists"
End If
lRow = lRow + 1
End With
Wend
sht.Activate

End Sub

--
Hope that helps.

Vergel Adriano


"Mr. Matt" wrote:

I'd like to create a new tab for each cell in column A that has a value in it
using that cell's value as the tab name. I have a tab that the new ones
should all be copies of named "Template Tab". I'd like this to loop until it
finds a blank cell in column A and then stop.

Thanks in advance for your help!!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Use Cell Values to Create Tabs with specific names

this should do it then..

Sub test()
Dim lRow As Long
Dim sht As Worksheet
Dim shtTest As Worksheet

lRow = 1
Set sht = ActiveSheet
While sht.Range("A" & lRow).Text < ""
With sht.Range("A" & lRow)
On Error Resume Next
Set shtTest = Nothing
Set shtTest = Worksheets(.Text)
On Error GoTo 0
If shtTest Is Nothing Then
Worksheets("Template Tab").Copy
After:=Worksheets(Worksheets.Count)
ActiveSheet.Name = .Text
Else
Debug.Print .Text; " tab already exists"
End If
lRow = lRow + 1
End With
Wend
sht.Activate

End Sub





--
Hope that helps.

Vergel Adriano


"Mr. Matt" wrote:

This is great, thanks a lot. The only thing I'd like to change is that the
last tab created be the last tab in the workbook. In other words, it would
be great if the first new tab were created at the end of all other existing
tabs and the rest of the new tabs followed that one with the final one being
last in the workbook.

Thanks again.

"Vergel Adriano" wrote:

maybe something like this:

Sub test()
Dim lRow As Long
Dim sht As Worksheet
Dim shtTest As Worksheet

lRow = 1
Set sht = ActiveSheet
While sht.Range("A" & lRow).Text < ""
With sht.Range("A" & lRow)
On Error Resume Next
Set shtTest = Nothing
Set shtTest = Worksheets(.Text)
On Error GoTo 0
If shtTest Is Nothing Then
Worksheets("Template Tab").Copy After:=sht
ActiveSheet.Name = .Text
Else
Debug.Print .Text; " tab already exists"
End If
lRow = lRow + 1
End With
Wend
sht.Activate

End Sub

--
Hope that helps.

Vergel Adriano


"Mr. Matt" wrote:

I'd like to create a new tab for each cell in column A that has a value in it
using that cell's value as the tab name. I have a tab that the new ones
should all be copies of named "Template Tab". I'd like this to loop until it
finds a blank cell in column A and then stop.

Thanks in advance for your help!!

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
How do I create a list (Word) of the names on Excel worksheet tabs PT[_2_] Excel Worksheet Functions 3 February 23rd 07 05:24 PM
Concatenating cell values to create sheet names XLDabbler Excel Discussion (Misc queries) 3 August 29th 05 09:55 PM
How dynamically create routing slip based on names in specific cel arich Excel Discussion (Misc queries) 1 August 25th 05 11:52 PM
How do I create a formula to add values from specific fields? Greg Excel Worksheet Functions 1 December 14th 04 03:10 PM
How do I create a formula to add values from specific fields? cabodiamonds Excel Worksheet Functions 1 December 14th 04 04:53 AM


All times are GMT +1. The time now is 06:26 PM.

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

About Us

"It's about Microsoft Excel"