View Single Post
  #20   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

presented the following explanation :
On Apr 21, 12:02*pm, GS wrote:
was thinking very hard :

Garry:


I am trying to make this process as easy for my intructors as possible
and yes there is a need to have a sheet for each student. *Having the
worksheets name change automatically was just an idea I had to help
make the process as automated as possible. *The intent is to have the
Class Commanders of each class only have to enter the names in once
(on the "input sheet"). *I have verified that the cells on the "input
sheet" are cells B13 through B30 and yes there are 18 different
worksheets named Stud1 through Stud18. *Hope that helps.
Brad


Brad,
Thanks for the additional info. I've duplicated your scenario and ran
Paul's code 'as is' and it works fine for me. However, it could be
condensed somewhat to obviate the overhead of the unecessary
variables...

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

--
Garry

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


Gentlemen,

We have success again! I looked at the first bit of code that was
given to me and relized that after the first try of getting it too
work, it had changed the name of the first worksheet. After that it
wasn't working because it was looking for a sheet named "Stud1" and
couldnt find it. I renamed it back to Stud1 and ran the Macro and it
work perfectly. However, the second bit of code:

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?


Read my previous post!

--
Garry

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