View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Paul Robinson Paul Robinson is offline
external usenet poster
 
Posts: 208
Default Changing name of worksheet based on data in cell of another worksheet

Hi
try this

Sub ChangeTabNames()
Dim myNames As Range, mycell As Range
Dim Temp As String, i As Integer

Application.Screenupdating = False

Set myNames = Worksheets("Master").Range("B13:B30")
i = 1
For Each mycell In myNames
Temp = "Stud" & i
Worksheets(Temp).Name = mycell.Value
i = i + 1
Next mycell
End Sub

If using excel 2003 go to Tools, Macro, Visual Basic Editor. In the
toolbar you get go to Insert then Module. Paste the above code into
here. You can now close the VBE. Back in Excel proper go to Tools,
Macro, Macros.. and run the macro. It doesnt matter which sheet is
visible. Try it out on a copy of your worksheet first to test it is
OK!
If using Excel 2007 (2010?) click the round Home button and choose
Excel Options. Click on the Developer Tab option. Back in Excel proper
click on the Developer Tab and bring up the editor etc.

regards
Paul

On Apr 20, 3:11*pm, wrote:
I have an excel workbook, with a "master" worksheet for data input and
have 18 other worksheets titled Stud1 through Stud18. *I am trying to
have the names of the "Stud" worksheets automatically change to the
student's lastnames on the "master" worksheet (there is a column on
the master worksheet named "lastname" from B13 to B30. *The lastname
entered in B13 should be the name of the "Stud1" worksheet and B14 the
name of "Stud14" worksheet, and so on.) *I have little to no VBA
experience and would love some help with this. *Anyone out there have
any ideas?