name the sheet the same as the file name

  • Thread starter Thread starter jjnotme
  • Start date Start date
J

jjnotme

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
 
hi
sheet1.name = activeworkbook.name
or
activesheet.name = activeworkbook.name

regards
FSt1
 
jjnotme said:
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.
 
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
 
ward376 said:
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.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top