![]() |
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 |
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 |
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 |
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 |
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) |
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) |
All times are GMT +1. The time now is 02:02 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com