name each sheet from a list on sheet 1

F

Flumoxed

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.
 
M

Mike H

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
 
G

Gary''s Student

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
 
R

Rick Rothstein

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
 
B

Bernard Liengme

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top