Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 142
Default rename worksheets using existing cell

I have a spreadsheet with 65 or so worksheets. I need to rename each
worksheet based on info found in cell a15. However cell a15 is last name
first name and I want to pick last name plus the 1st letter of the first
name. Can you assist me? Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default rename worksheets using existing cell

Try the below macro..

Sub Macro1()
For Each Sh In Worksheets
If Sh.Range("A15") < "" Then
arrTemp = Split(Sh.Range("A15") & " ")
Sh.Name = arrTemp(0) & " " & Left(arrTemp(1), 1)
End If
Next
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Jerry" wrote:

I have a spreadsheet with 65 or so worksheets. I need to rename each
worksheet based on info found in cell a15. However cell a15 is last name
first name and I want to pick last name plus the 1st letter of the first
name. Can you assist me? Thanks in advance.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default rename worksheets using existing cell

Hi,

Right click any sheet tab, view code and paste this in and run it

Sub rename()
On Error Resume Next
For x = 1 To Worksheets.Count
shname = Sheets(x).Range("A15")
y = Split(shname, " ")
newname = y(0) & " " & Left(y(1), 1)
Sheets(x).Name = newname
newname = ""
Next
End Sub

Mike

"Jerry" wrote:

I have a spreadsheet with 65 or so worksheets. I need to rename each
worksheet based on info found in cell a15. However cell a15 is last name
first name and I want to pick last name plus the 1st letter of the first
name. Can you assist me? Thanks in advance.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default rename worksheets using existing cell

and just for the exercise another method with a better error handler

Sub rename()
On Error GoTo Badname:
For x = 1 To Worksheets.Count
shname = Split(Sheets(x).Range("A15"), " ")
Sheets(x).Name = shname(0) & " " & Left(shname(1), 1)
Next
Exit Sub
Badname:
MsgBox "Sheets " & x & " cannot be renamed " & Sheets(x).Range("A15")
Resume Next
End Sub

Mike

"Mike H" wrote:

Hi,

Right click any sheet tab, view code and paste this in and run it

Sub rename()
On Error Resume Next
For x = 1 To Worksheets.Count
shname = Sheets(x).Range("A15")
y = Split(shname, " ")
newname = y(0) & " " & Left(y(1), 1)
Sheets(x).Name = newname
newname = ""
Next
End Sub

Mike

"Jerry" wrote:

I have a spreadsheet with 65 or so worksheets. I need to rename each
worksheet based on info found in cell a15. However cell a15 is last name
first name and I want to pick last name plus the 1st letter of the first
name. Can you assist me? Thanks in advance.

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
Default Cell format of existing Worksheets got changed automatical NGBalaji Excel Discussion (Misc queries) 1 May 21st 10 08:32 AM
Rename rather than overwrite existing file jnf40 Excel Programming 4 August 31st 07 05:40 AM
Rename all existing worksheet tabs MikeM Excel Discussion (Misc queries) 14 October 20th 06 03:29 AM
Rename existing tabs Dawn Rhoads Excel Programming 8 May 27th 05 10:00 PM
Macro to rename all worksheets with cell value in each sheet Max Excel Programming 1 July 11th 03 10:58 AM


All times are GMT +1. The time now is 02:20 AM.

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"