Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Cue Cue is offline
external usenet poster
 
Posts: 47
Default Rename Worksheet Tab as File Name Using a Macro

Hello,

I am trying to rename a worksheet tab using the name of the workbook. Each
code I've tried does not work. Does anybody have a simple macro to accomplish
this?

Thanks.
--
Cue
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,819
Default Rename Worksheet Tab as File Name Using a Macro

Perhaps assign file name to variable, then assign variable to Tab.

Cue wrote:
Hello,

I am trying to rename a worksheet tab using the name of the workbook. Each
code I've tried does not work. Does anybody have a simple macro to accomplish
this?

Thanks.


  #3   Report Post  
Posted to microsoft.public.excel.misc
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Rename Worksheet Tab as File Name Using a Macro

Sub RenameSheet()
Dim myname
myname = ThisWorkbook.Name
ActiveSheet.Select
ActiveSheet.Name = myname
Range("A1").Select
End Sub

Vaya con Dios,
Chuck, CABGx3



"Cue" wrote:

Hello,

I am trying to rename a worksheet tab using the name of the workbook. Each
code I've tried does not work. Does anybody have a simple macro to accomplish
this?

Thanks.
--
Cue

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,942
Default Rename Worksheet Tab as File Name Using a Macro

hi
Sheets("sheet1").Name = ActiveWorkbook.Name

regards
FSt1

"Cue" wrote:

Hello,

I am trying to rename a worksheet tab using the name of the workbook. Each
code I've tried does not work. Does anybody have a simple macro to accomplish
this?

Thanks.
--
Cue

  #5   Report Post  
Posted to microsoft.public.excel.misc
Cue Cue is offline
external usenet poster
 
Posts: 47
Default Rename Worksheet Tab as File Name Using a Macro

Great! Thanks to both of you for your assistance.

One thing i did not account for... Is there a way rename the tab with the
filename with the ".xls"?
--
Cue


  #6   Report Post  
Posted to microsoft.public.excel.misc
Cue Cue is offline
external usenet poster
 
Posts: 47
Default Rename Worksheet Tab as File Name Using a Macro

Excuse me...
Is there a way rename the tab with the filename without the ".xls"?
--
Cue


"Cue" wrote:

Great! Thanks to both of you for your assistance.

One thing i did not account for... Is there a way rename the tab with the
filename with the ".xls"?
--
Cue

  #7   Report Post  
Posted to microsoft.public.excel.misc
Cue Cue is offline
external usenet poster
 
Posts: 47
Default Rename Worksheet Tab as File Name Using a Macro

I'll try that. Thanks.
--
Cue


"Bob I" wrote:

Perhaps assign file name to variable, then assign variable to Tab.

Cue wrote:
Hello,

I am trying to rename a worksheet tab using the name of the workbook. Each
code I've tried does not work. Does anybody have a simple macro to accomplish
this?

Thanks.


.

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,942
Default Rename Worksheet Tab as File Name Using a Macro

hi
now you will have to use variables.
Sub nametab()
Dim s As String
Dim ss As String
s = ActiveWorkbook.Name
ss = Left(s, Len(s) - 4)
Sheets("Sheet1").Name = ss
End Sub

regards
FSt1

"Cue" wrote:

Excuse me...
Is there a way rename the tab with the filename without the ".xls"?
--
Cue


"Cue" wrote:

Great! Thanks to both of you for your assistance.

One thing i did not account for... Is there a way rename the tab with the
filename with the ".xls"?
--
Cue

  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 561
Default Rename Worksheet Tab as File Name Using a Macro

I would suggest to try the following code.
1) It will work, as expected, in "Excel 2007 and 2010"
2) It may be run from within a Module and it will rename the Active Sheet at
that moment.
There is alao another "workaround" by checking the Excels version and then
cut-off 4 or 5 characters from the end.
----------------------
Sub NameTab()
ActiveSheet.Name = Left(ActiveWorkbook.Name, InStr(ActiveWorkbook.Name,
".") - 1)
End Sub
--------------
Micky



"Cue" wrote:

I'll try that. Thanks.
--
Cue


"Bob I" wrote:

Perhaps assign file name to variable, then assign variable to Tab.

Cue wrote:
Hello,

I am trying to rename a worksheet tab using the name of the workbook. Each
code I've tried does not work. Does anybody have a simple macro to accomplish
this?

Thanks.


.

  #10   Report Post  
Posted to microsoft.public.excel.misc
Cue Cue is offline
external usenet poster
 
Posts: 47
Default Rename Worksheet Tab as File Name Using a Macro

Thanks everyone! All your solutions worked!

I found this similar to CLR solution:

Sheets("Sheet2").Name = Replace(ActiveWorkbook. Name, ".xls", "")

Thanks again everyone for your help!
--
Cue


"Cue" wrote:

I'll try that. Thanks.
--
Cue


"Bob I" wrote:

Perhaps assign file name to variable, then assign variable to Tab.

Cue wrote:
Hello,

I am trying to rename a worksheet tab using the name of the workbook. Each
code I've tried does not work. Does anybody have a simple macro to accomplish
this?

Thanks.


.



  #11   Report Post  
Posted to microsoft.public.excel.misc
Cue Cue is offline
external usenet poster
 
Posts: 47
Default Rename Worksheet Tab as File Name Using a Macro

Thanks everyone. Of course, all of your solutions worked. Now I have to
decide which one to use.

Thanks again to all of you!
--
Cue

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
Macro: Copy a worksheet and rename it to a specified value mitch Excel Discussion (Misc queries) 2 February 16th 09 05:43 PM
Macro to copy a worksheet and rename based upon text entered in 1 edeaston Excel Discussion (Misc queries) 5 December 5th 08 05:47 PM
Rename worksheet in macro JBW Excel Worksheet Functions 1 September 24th 07 05:58 PM
new worksheet and rename from cell contents macro Henry Excel Worksheet Functions 1 September 12th 06 10:35 AM
How to set SAVE AS file name to equal A1 contents when rename file E Excel Discussion (Misc queries) 0 October 19th 05 08:36 PM


All times are GMT +1. The time now is 12:43 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"