Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Automatic sheet naming

Is it possible with a macro to have all let's say 20
names on a first sheet and use them as a base to name 20
new to create sheet's?

Like:

x = A2
Sheets("Sheet2").Name = x

And so on

Thanks in advance,
Hans Weustink
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Automatic sheet naming

This code will loop through a column of data and create a new sheet name
from the data.

It does not check for length or invalid name characters.


Sub MakeNamedSheets()

' Loop through column where sheet names are stored
For Each cell In Sheet1.Range("A1:A65536")
If cell = "" Then Exit For
' Add a New Sheet
Sheets.Add
Sheets(ActiveSheet.Name).Name = cell
Next cell

End Sub


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Automatic sheet naming

Thank you Barry!

It works great.

-----Original Message-----
This code will loop through a column of data and create

a new sheet name
from the data.

It does not check for length or invalid name characters.


Sub MakeNamedSheets()

' Loop through column where sheet names are stored
For Each cell In Sheet1.Range("A1:A65536")
If cell = "" Then Exit For
' Add a New Sheet
Sheets.Add
Sheets(ActiveSheet.Name).Name = cell
Next cell

End Sub


*** Sent via Developersdex http://www.developersdex.com

***
Don't just participate in USENET...get rewarded for it!
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Automatic sheet naming

Building on Barry's code to do the checking

Sub MakeNamedSheets()
Dim TempName as String
' Loop through column where sheet names are stored
For Each cell In Sheet1.Range("A1:A65536")
TempName = Cell.Text
If TempName = "" Then Exit For 'sub aborted as end of names block
' Add a New Sheet
Sheets.Add
If Len(TempName) 30 Then
TempName = Left(TempName, 10) & " ... " & Right(TempName, 3)
'length of 18
End If
'Finally, check TempName does not contain :, \, /, ?, *, [ or ]
Do While (InStr(TempName, ":") Or InStr(TempName, "\") Or _
InStr(TempName, "/") Or InStr(TempName, "?") Or _
InStr(TempName, "*") Or InStr(TempName, "[") Or _
InStr(TempName, "]"))
TempName = InputBox("Sheet name contains :, \, /, ?, *, [ or ]." _
& "Please edit to remove.","Title", TempName)
Loop
cell.Value = TempName 'optional
Sheets(ActiveSheet.Name).Name = TempName
Next cell

End Sub

regards
Paul
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 a sheet the same as a cell in that sheet des-sa[_2_] Excel Discussion (Misc queries) 3 July 16th 08 08:08 PM
Naming a sheet Mike Excel Discussion (Misc queries) 3 March 7th 07 08:43 AM
naming sheet tab artist4christ Excel Worksheet Functions 5 January 17th 07 11:54 PM
Naming Sheet mehare Excel Discussion (Misc queries) 4 August 14th 06 06:20 PM
Workbook "Sheet" Naming comotoman Excel Discussion (Misc queries) 4 September 30th 05 09:49 PM


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