Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Change sheet name


I'm trying to write code that will rename a worksheet with
the value in a cell. ex: cell a5 (sheet1) value is
NewName. I'd like to grab that text and change the name
of sheet1 to NewName. Any suggestions? Thanks in advance!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Change sheet name

Worksheets(1).Name = Worksheets(1).Cells(5, 1).Value

This will work, but I'll post an improvement in a bit.
- Pikus


---
Message posted from http://www.ExcelForum.com/

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Change sheet name

Matt,

This worked for me in Excel 2002

ActiveSheet.Name = Range("A5")

but errors out if the cell is blank - so add something to catch the error.

hth

--
steveb
(Remove 'NOSPAM' from email address if replying direct)


"Matt" wrote in message
...

I'm trying to write code that will rename a worksheet with
the value in a cell. ex: cell a5 (sheet1) value is
NewName. I'd like to grab that text and change the name
of sheet1 to NewName. Any suggestions? Thanks in advance!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Change sheet name

Sheet1.Name = Sheet1.Cells(5, 1).Value - Piku

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Change sheet name

Matt

From Bob Phillips..........

Private Sub Worksheet_Change(ByVal Target As Range)
'autoname the worksheet Tab from value in A5
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("A5")) Is Nothing Then Exit Sub
On Error GoTo CleanUp
Application.EnableEvents = False
With Target
If .Value < "" Then
Me.Name = .Value
End If
End With
CleanUp:
Application.EnableEvents = True
End Sub

Alternate on a button or shortcut key.

Sub SheetName()
ActiveSheet.Name = Range("a5")
End Sub

Gord Dibben Excel MVP

On Wed, 12 May 2004 10:45:34 -0700, "Matt"
wrote:


I'm trying to write code that will rename a worksheet with
the value in a cell. ex: cell a5 (sheet1) value is
NewName. I'd like to grab that text and change the name
of sheet1 to NewName. Any suggestions? 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
how to change formula in shared sheet without loss of change histo DCE Excel Worksheet Functions 1 July 23rd 08 05:09 PM
How to change the size of characters in Sheet 1, Sheet2, Sheet 3 Mark 414 Excel Discussion (Misc queries) 3 May 23rd 08 11:39 PM
How do I change the Excel sheet tab bar to display more sheet tabs Rockie Excel Discussion (Misc queries) 3 August 18th 06 02:29 PM
Links in Embedded doc within sheet don't change when sheet is copi Dan k Excel Discussion (Misc queries) 0 May 11th 06 05:41 PM
Change workbook sheet reference using cell A1 to change a vairable Reed Excel Worksheet Functions 4 January 20th 05 07:15 PM


All times are GMT +1. The time now is 10:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"