Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default name each sheet from a list on sheet 1

I am new to excel but have to set the following up:
I have a front sheet with student names on it. Then I have up to 44 sheets
behind this. I just want to be able to somehow get those names onto the
sheet tab at the bottom of the page in the same order as on the list then use
this as a template.
So at the top of the list I have say Fred Bloggs: I need him to have his
name on the tab at the bottom instead of it saying "sheet 2" and then second
on list as name on bottom of third sheet tab etc. The data on the sheets
that refer to sheet one has already been set up but I have to do this 24
times and I'm sure there must be a quicker way than typing it in by hand each
time. Is there? Thank you very much.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default name each sheet from a list on sheet 1

Hi,

Right click any sheet tab, view code and paste this in and run it. The code
assumes the names are in Sheet 1 A1 down,

Sub name_Sheets()
On Error Resume Next
For x = 2 To Worksheets.Count
Sheets(x).Name = Sheets("Sheet1").Cells(x - 1, 1).Value
Next
End Sub


Mike

"Flumoxed" wrote:

I am new to excel but have to set the following up:
I have a front sheet with student names on it. Then I have up to 44 sheets
behind this. I just want to be able to somehow get those names onto the
sheet tab at the bottom of the page in the same order as on the list then use
this as a template.
So at the top of the list I have say Fred Bloggs: I need him to have his
name on the tab at the bottom instead of it saying "sheet 2" and then second
on list as name on bottom of third sheet tab etc. The data on the sheets
that refer to sheet one has already been set up but I have to do this 24
times and I'm sure there must be a quicker way than typing it in by hand each
time. Is there? Thank you very much.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default name each sheet from a list on sheet 1

Put the names in column A of the first sheet.

The first sheet will NOT be renamed.

Option Explicit
Sub sheetnamer()
Dim i As Long, n As Long, j As Long, shetcnt As Long
shetcnt = Sheets.Count
Sheets(1).Activate
n = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To n
j = i + 1
If j shetcnt Then Exit Sub
Sheets(j).Name = Cells(i, 1).Value
Next
End Sub


--
Gary''s Student - gsnu200829


"Flumoxed" wrote:

I am new to excel but have to set the following up:
I have a front sheet with student names on it. Then I have up to 44 sheets
behind this. I just want to be able to somehow get those names onto the
sheet tab at the bottom of the page in the same order as on the list then use
this as a template.
So at the top of the list I have say Fred Bloggs: I need him to have his
name on the tab at the bottom instead of it saying "sheet 2" and then second
on list as name on bottom of third sheet tab etc. The data on the sheets
that refer to sheet one has already been set up but I have to do this 24
times and I'm sure there must be a quicker way than typing it in by hand each
time. Is there? Thank you very much.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default name each sheet from a list on sheet 1

You said you have more worksheets set up than you have student's names to
put on them. Assuming you will want to use this macro next year and the year
after, and further assuming you might have less students in one of the
subsequent years, the macro below names the worksheets, starting with the
2nd one, according to your list and then renames the subsequent worksheets
back to SheetX (where X is the appropriate sheet number) so you won't have
left over names on the tabs from previous years. Just change the data in the
3 Const statements to match your actual conditions...

Sub DistributeNames()
Dim X As Long
Dim LastRow As Long

Const RowWithFirstName As Long = 2
Const ColumnWithNames As String = "A"
Const FrontSheetname As String = "Sheet1"

With Worksheets(FrontSheetname)
LastRow = .Cells(.Rows.Count, ColumnWithNames).End(xlUp).Row
For X = 2 To Worksheets.Count
If X <= LastRow Then
Worksheets(X).Name = .Cells(X, ColumnWithNames).Value
Else
Worksheets(X).Name = "Sheet" & X
End If
Next
End With
End Sub

--
Rick (MVP - Excel)


"Flumoxed" wrote in message
...
I am new to excel but have to set the following up:
I have a front sheet with student names on it. Then I have up to 44
sheets
behind this. I just want to be able to somehow get those names onto the
sheet tab at the bottom of the page in the same order as on the list then
use
this as a template.
So at the top of the list I have say Fred Bloggs: I need him to have his
name on the tab at the bottom instead of it saying "sheet 2" and then
second
on list as name on bottom of third sheet tab etc. The data on the sheets
that refer to sheet one has already been set up but I have to do this 24
times and I'm sure there must be a quicker way than typing it in by hand
each
time. Is there? Thank you very much.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,393
Default name each sheet from a list on sheet 1

Sub MakeSheets()
Worksheets("Sheet1").Activate
Howmany = WorksheetFunction.CountA(Range("A:A"))
sheetcount = Worksheets.Count
For j = 1 To Howmany
Worksheets.Add After:=Worksheets(sheetcount)
sheetcount = sheetcount + 1
Set wks = Worksheets(sheetcount)
wks.Name = Worksheets("Sheet1").Cells(j, 1).Value
Next j
End Sub


works for me
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Flumoxed" wrote in message
...
I am new to excel but have to set the following up:
I have a front sheet with student names on it. Then I have up to 44
sheets
behind this. I just want to be able to somehow get those names onto the
sheet tab at the bottom of the page in the same order as on the list then
use
this as a template.
So at the top of the list I have say Fred Bloggs: I need him to have his
name on the tab at the bottom instead of it saying "sheet 2" and then
second
on list as name on bottom of third sheet tab etc. The data on the sheets
that refer to sheet one has already been set up but I have to do this 24
times and I'm sure there must be a quicker way than typing it in by hand
each
time. Is there? Thank you very much.



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
Need help Taking alot data from one sheet (if not blank) and copying toa list on another sheet. Alex Zuniga Excel Worksheet Functions 1 November 25th 09 11:54 PM
Copy Paste from Class Sheet to Filtered List on Combined Sheet [email protected] Excel Programming 6 September 16th 08 04:30 PM
Generate sheet names from list, assign data to summary sheet. [email protected][_2_] Excel Programming 4 June 20th 07 09:17 PM
adding data from one sheet to another sheet as a dropdown list bo. gatorguy Excel Discussion (Misc queries) 1 February 18th 05 10:51 PM
how to find and copy values on sheet 2, based on a list on sheet 1 evanmacnz Excel Programming 4 February 7th 05 08:33 PM


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