Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how to find and replace content of a specific cell based on its ad | Excel Discussion (Misc queries) | |||
Rename Worksheet Tabs per Cell Content | Excel Programming | |||
Rename active sheet to contents of specific cell | Excel Programming | |||
Returning Specific Cell Content using IF Statement | Excel Discussion (Misc queries) | |||
Returning Specific Cell Content using IF Statement | Excel Discussion (Misc queries) |