Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Rename sheet with content in specific cell

Hi there,
I don't know if this can be done using macro but if it's possible, please
help.

Is there a way to rename the sheet with whatever the content in cell A1? And
do the same thing each sheet in the workbook.
For example, if cell A1 for the first sheet has the word "Project" then that
sheet should be renamed it to "Project". If cell A1 for the second sheet has
the word "Time", then that sheet should be renamed it to "Time". And keep on
doing that for all the sheets in the workbook regardless of how many sheets
there are.

Thank you in advance. :)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Rename sheet with content in specific cell

Sub RenameAllSheets()

Dim ws As Worksheet

For Each ws In Worksheets
On Error Resume Next
ws.Name = ws.Range("A1")
If Err.Number 0 Then
On Error GoTo 0 'Reset error trapping ASAP
MsgBox "Could not rename sheet " & _
ws.Name & vbCrLf & vbCrLf & _
"Probably due to invalid sheet name"
End If
Next ws

End Sub

--
Regards,

OssieMac


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Rename sheet with content in specific cell

Sub Sheetname_cell()
Dim Sh As Worksheet
Application.ScreenUpdating = False
For Each Sh In ThisWorkbook.Worksheets
On Error Resume Next
Sh.Name = Sh.Range("A1").Value
'next lines cover duplicate names
If Err.Number 0 Then
MsgBox "Change the name of : " & Sh.Name & " manually"
Err.Clear
End If
On Error GoTo 0
Next
Application.ScreenUpdating = True
End Sub


Gord Dibben MS Excel MVP

On Mon, 5 Oct 2009 14:26:16 -0700, Don Doan
wrote:

Hi there,
I don't know if this can be done using macro but if it's possible, please
help.

Is there a way to rename the sheet with whatever the content in cell A1? And
do the same thing each sheet in the workbook.
For example, if cell A1 for the first sheet has the word "Project" then that
sheet should be renamed it to "Project". If cell A1 for the second sheet has
the word "Time", then that sheet should be renamed it to "Time". And keep on
doing that for all the sheets in the workbook regardless of how many sheets
there are.

Thank you in advance. :)


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Rename sheet with content in specific cell

Thank you all for your help. I guess you can do many things with VBA. THANK
YOU!!!!

"Gord Dibben" wrote:

Sub Sheetname_cell()
Dim Sh As Worksheet
Application.ScreenUpdating = False
For Each Sh In ThisWorkbook.Worksheets
On Error Resume Next
Sh.Name = Sh.Range("A1").Value
'next lines cover duplicate names
If Err.Number 0 Then
MsgBox "Change the name of : " & Sh.Name & " manually"
Err.Clear
End If
On Error GoTo 0
Next
Application.ScreenUpdating = True
End Sub


Gord Dibben MS Excel MVP

On Mon, 5 Oct 2009 14:26:16 -0700, Don Doan
wrote:

Hi there,
I don't know if this can be done using macro but if it's possible, please
help.

Is there a way to rename the sheet with whatever the content in cell A1? And
do the same thing each sheet in the workbook.
For example, if cell A1 for the first sheet has the word "Project" then that
sheet should be renamed it to "Project". If cell A1 for the second sheet has
the word "Time", then that sheet should be renamed it to "Time". And keep on
doing that for all the sheets in the workbook regardless of how many sheets
there are.

Thank you in advance. :)



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Rename sheet with content in specific cell

Just about anything you need to do can be done with VBA.

Thanks for the feedback.


Gord

On Mon, 5 Oct 2009 16:26:01 -0700, Don Doan
wrote:

Thank you all for your help. I guess you can do many things with VBA. THANK
YOU!!!!

"Gord Dibben" wrote:

Sub Sheetname_cell()
Dim Sh As Worksheet
Application.ScreenUpdating = False
For Each Sh In ThisWorkbook.Worksheets
On Error Resume Next
Sh.Name = Sh.Range("A1").Value
'next lines cover duplicate names
If Err.Number 0 Then
MsgBox "Change the name of : " & Sh.Name & " manually"
Err.Clear
End If
On Error GoTo 0
Next
Application.ScreenUpdating = True
End Sub


Gord Dibben MS Excel MVP

On Mon, 5 Oct 2009 14:26:16 -0700, Don Doan
wrote:

Hi there,
I don't know if this can be done using macro but if it's possible, please
help.

Is there a way to rename the sheet with whatever the content in cell A1? And
do the same thing each sheet in the workbook.
For example, if cell A1 for the first sheet has the word "Project" then that
sheet should be renamed it to "Project". If cell A1 for the second sheet has
the word "Time", then that sheet should be renamed it to "Time". And keep on
doing that for all the sheets in the workbook regardless of how many sheets
there are.

Thank you 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 find and replace content of a specific cell based on its ad IVUSKA Excel Discussion (Misc queries) 4 November 5th 08 03:13 PM
Rename Worksheet Tabs per Cell Content JEFF Excel Programming 2 May 15th 07 06:41 PM
Rename active sheet to contents of specific cell burl_rfc Excel Programming 3 February 28th 06 11:34 PM
Returning Specific Cell Content using IF Statement weeclaire Excel Discussion (Misc queries) 2 February 17th 06 01:48 PM
Returning Specific Cell Content using IF Statement weeclaire Excel Discussion (Misc queries) 0 February 17th 06 09:25 AM


All times are GMT +1. The time now is 10:00 PM.

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"