record macro "That name is not valid."

H

highlifesipper

I'm trying to learn how to use macros and start out by trying to record one.

I went:
Tools
Macro
Record New Macro....

For "Macro name:" I left "Macro1"

click "OK" and get an error message...."That name is not valid."

I've tried everything....starting with a letter, no spaces, opening a new
workbook...keep getting the same error message
 
C

Conan Kelly

highlifesipper,

Macro names can not contain spaces.

There are some other restrictions, but I don't remeber them off the top of
my head.

HTH,

Conan
 
T

Tyro

Macro1 is a valid name. I've used it many times when I'm not going to keep
the macro. Try a name like ABCDEF and see what happens.

Tyro
 
J

JLatham

Basically, without looking up a reference with a specific list, you can't
have spaces in a macro name, and the name must start with a letter of the
alphabet. There are probably some special characters that can't be used, but
I don't know what they are at the moment, because I always stick to a few
'rules' when I create a Sub or Function name:
begin the name with a letter of the alphabet
only use letters from the alphabet, numbers and the underscore ( _ )
character within the name.
Keep it reasonably short.

Examples of names I might use:
MyFirstMacro
My_First_Macro
sort_ByNumber
sort_ByName
sort_BySSAN

Conan is correct, "Macro1" should be a valid name as long as it doesn't have
any spaces in it anywhere. And it is odd that Excel is telling
highlifesipper that the name is invalid, when it created the name itself!
(one good reason for never naming a macro by starting the name with the word
Macro followed by a number).

If highlifesipper had tried manually entering the name "Macro1" and
continuing, I could perhaps understand why he's getting an error (Excel may
have previously used that name and so wouldn't like someone trying to use it
again). But I don't understand why Excel is assigning that name and then
refusing to validate it.
 
D

Dave Peterson

Just a guess--and I got a different error when I tested this.

Do you have a module named Macro1?
Did you rename the project to Macro1?

Did you use that name somewhere else?
 

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