ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   name the sheet the same as the file name (https://www.excelbanter.com/excel-programming/407389-name-sheet-same-file-name.html)

jjnotme[_2_]

name the sheet the same as the file name
 

Thanks to everyone who has been helping me with my macro.
I have another question.
I need the sheet to have the same name as the file name. I got it to
work by using an input box, where the user has to enter the file name.
I would like to avoid having to use the input box, and have the macro
do it automatically. Is there any way to do that? I am using Excel
2003.

Thanks, Carol

FSt1

name the sheet the same as the file name
 
hi
sheet1.name = activeworkbook.name
or
activesheet.name = activeworkbook.name

regards
FSt1

"jjnotme" wrote:


Thanks to everyone who has been helping me with my macro.
I have another question.
I need the sheet to have the same name as the file name. I got it to
work by using an input box, where the user has to enter the file name.
I would like to avoid having to use the input box, and have the macro
do it automatically. Is there any way to do that? I am using Excel
2003.

Thanks, Carol


Howard Kaikow

name the sheet the same as the file name
 
"jjnotme" wrote in message
...

Thanks to everyone who has been helping me with my macro.
I have another question.
I need the sheet to have the same name as the file name. I got it to
work by using an input box, where the user has to enter the file name.
I would like to avoid having to use the input box, and have the macro
do it automatically. Is there any way to do that? I am using Excel
2003.

Thanks, Carol


In general, filenames might be too long, or contain characters not allowed
in sheet names.



ward376

name the sheet the same as the file name
 
Sheet names are limited to 31 characters (through xl 2003 afaik). You
could try something like this...

ActiveSheet.Name = Left(ThisWorkbook.Name, 31) 'or right as far as
that goes

Cliff Edwards

Howard Kaikow

name the sheet the same as the file name
 
"ward376" wrote in message
...
Sheet names are limited to 31 characters (through xl 2003 afaik). You
could try something like this...

ActiveSheet.Name = Left(ThisWorkbook.Name, 31) 'or right as far as
that goes


That raises the issue of uniqueness of sheet names as the leading/trailing
31 characters might be the same for more than one file.
Also, my recollection is that there are characters allowed in filenames that
are not allowed in sheetnames.



ward376

name the sheet the same as the file name
 
Yes it does raise the issue of duplicate sheet names. And there are
characters allowed/not allowed for file and sheet names, but more are
allowed for sheet names than file names.

* . " / \ [ ] : ; | = , not allowed in filenames (dot not allowed at
end)

: / \ ? * [ ] not allowed in sheet names

Cliff Edwards


All times are GMT +1. The time now is 04:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com