Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default macro to change tab name to file name

I need a macro to change the name of a tab to the name of the Excel file.

Here's what I've got (the original name of the tab is "compliled"). It
doesn't work:

Sheets("compiled").Select
Sheets("compiled").Name = Filename

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default macro to change tab name to file name

Is Filename a variable? if so, it works fine. Make sure there are no invalid
characters such as /

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"jeremy nickels" wrote in message
...
I need a macro to change the name of a tab to the name of the Excel file.

Here's what I've got (the original name of the tab is "compliled"). It
doesn't work:

Sheets("compiled").Select
Sheets("compiled").Name = Filename

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default macro to change tab name to file name

Like Bob said, if Filename is a variable holding the filename, then it
works fine.
Filename=ActiveWorkbook.Name
Sheets("compiled").Name = Filename
or
Sheets("compiled").Name = ActiveWorkbook.Name

jeremy nickels wrote:
I need a macro to change the name of a tab to the name of the Excel file.

Here's what I've got (the original name of the tab is "compliled"). It
doesn't work:

Sheets("compiled").Select
Sheets("compiled").Name = Filename

Thanks


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default macro to change tab name to file name

Thanks.

How do I keep the tab name from becoming "somefilename.xls"? I need to
leave the .xls off so that the tab name becomes just "somefilename".



"JW" wrote:

Like Bob said, if Filename is a variable holding the filename, then it
works fine.
Filename=ActiveWorkbook.Name
Sheets("compiled").Name = Filename
or
Sheets("compiled").Name = ActiveWorkbook.Name

jeremy nickels wrote:
I need a macro to change the name of a tab to the name of the Excel file.

Here's what I've got (the original name of the tab is "compliled"). It
doesn't work:

Sheets("compiled").Select
Sheets("compiled").Name = Filename

Thanks



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default macro to change tab name to file name

On Nov 12, 9:07 pm, jeremy nickels
wrote:
Thanks.

How do I keep the tab name from becoming "somefilename.xls"? I need to
leave the .xls off so that the tab name becomes just "somefilename".

"JW" wrote:
Like Bob said, if Filename is a variable holding the filename, then it
works fine.
Filename=ActiveWorkbook.Name
Sheets("compiled").Name = Filename
or
Sheets("compiled").Name = ActiveWorkbook.Name


jeremy nickels wrote:
I need a macro to change the name of a tab to the name of the Excel file.


Here's what I've got (the original name of the tab is "compliled"). It
doesn't work:


Sheets("compiled").Select
Sheets("compiled").Name = Filename


Thanks


Could do something like this, but it is assuming that the extension
will always be 4 characters, which will most likely work for what you
need.
Sheets("compiled").Name = _
Left(ActiveWorkbook.Name, _
Len(ActiveWorkbook.Name) - 4)



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default macro to change tab name to file name

Thanks JW. That was exactly what I needed.

"JW" wrote:

On Nov 12, 9:07 pm, jeremy nickels
wrote:
Thanks.

How do I keep the tab name from becoming "somefilename.xls"? I need to
leave the .xls off so that the tab name becomes just "somefilename".

"JW" wrote:
Like Bob said, if Filename is a variable holding the filename, then it
works fine.
Filename=ActiveWorkbook.Name
Sheets("compiled").Name = Filename
or
Sheets("compiled").Name = ActiveWorkbook.Name


jeremy nickels wrote:
I need a macro to change the name of a tab to the name of the Excel file.


Here's what I've got (the original name of the tab is "compliled"). It
doesn't work:


Sheets("compiled").Select
Sheets("compiled").Name = Filename


Thanks


Could do something like this, but it is assuming that the extension
will always be 4 characters, which will most likely work for what you
need.
Sheets("compiled").Name = _
Left(ActiveWorkbook.Name, _
Len(ActiveWorkbook.Name) - 4)


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
Recording macro to save file with name change jmcclain Excel Programming 2 February 22nd 07 02:55 PM
a macro that will change the file names within it after running Gai Excel Programming 1 November 16th 06 04:10 AM
Macro to change file name in Vlookup formula msdrolf Excel Programming 5 October 31st 06 08:04 PM
Change Code in Macro to specify file/folder to look in. Dtown Dawg Excel Programming 1 July 14th 06 06:34 PM
macro code to change file-opening password arunjoshi[_18_] Excel Programming 1 June 16th 05 08:49 AM


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