View Single Post
  #22   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default Changing name of worksheet based on data in cell of another worksheet

Clif McIrvin formulated the question :
"GS" wrote in message ...
presented the following explanation :
On Apr 21, 12:02 pm, GS wrote:
was thinking very hard :

[ ]

Sub ChangeTabNames2()
Dim rng As Range, sTemp As String, i As Integer
Application.ScreenUpdating = False
For Each rng In Worksheets("Sheet1").Range("B13:B30")
i = i + 1: sTemp = "Stud" & i
Sheets(sTemp).Name = sTemp & rng.Value
Next rng
End Sub

Does work, but appends the end of the name giving me a worksheet name
that looks like "Stud1Jones". Regardless it is working now. I want
to thank all of you for your help.


Oh, is there a way to undo it
without having to manually change the worksheet names back to Stud1
through Stud18?



If the master sheet is always the first sheet, and there are always 18
student sheets, this should rename the student sheets as Stud1 through
Stud18:

Sub ChangeTabNames3()
Dim sTemp As String, i As Integer
Application.ScreenUpdating = False
For i = 1 To 18
sTemp = "Stud" & i
Sheets(i + 1).Name = sTemp
Next i
End Sub


Clif,
I think he's got it working if he catches up to the replies. Not sure
how he's accessing this NG but he posted the same problem AFTER I
posted corrected code.

--
Garry

Free usenet access at
http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc