Rules for Sheet names

G

Guest

I am creating workbooks through a programmatic interface and need to know
what constraints there are on worksheet names. I understand that they have to
be no more than 31 (or 32?) characters in length, but are there other rules
like allowable characters that I need to be aware of?
 
N

Nick Hodge

Sparky

Avoid / \ ? * [ ] and the word history

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(e-mail address removed)
 
G

Gord Dibben

sparky

31 characters max.

Cannot use any of these \ / ? * [ ]


Gord Dibben Excel MVP
 
D

Dave Peterson

I'm guessing that you're going to validate a user's input so that you can rename
a sheet.

If that's close, then I just accept their input and try to rename and then check
for errors.

dim MyNewName as string
mynewname = inputbox(prompt:="what's the new name")
if mynewname = "" then
exit sub 'or whatever
end if

on error resume next
activesheet.name = mynewname
if err.number <> 0 then
msgbox "invalid name--not renamed"
err.clear
end if
on error goto 0

=====
There are some other rules--can't use "history" as a name (used with tracking
changes)

And you can't use a name that's alread in use in that workbook.
 
D

Dana DeLouis

Be aware of the "!" character also. You may have an error when using [...]
addressing.
For example, you can name a sheet with this character. For example
"Sheet!2"

This works...
[Sheet1].Select

But this would not work...
[Sheet!2].Select

HTH
 

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

Top