#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Macro Names

I'm having trouble finding what's excluded from use. Is there no list of
forbidden characters? I wanted the macro names to correspond to that of the
charts. Example "1A) MS" ... without the quotes. When that was rejected, I
assumed the bracket was the issue and rewrote to this: "1A_MS". No luck
either. So I assumed numerics as first charter were forbidden and chose:
"Chart 1A_MS". Rejected!

Help please.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro Names

You can't use a space in a name (the problem with your last attempt). Here
are the rules from Help ("Visual Basic Naming Rules")

Use the following rules when you name procedures, constants, variables, and
arguments in a Visual Basic module:

· You must use a letter as the first character.
· You can't use a space, period (.), exclamation mark (!), or the characters
@, &, $, # in the name.
· Name can't exceed 255 characters in length.
· Generally, you shouldn't use any names that are the same as the functions,
statements, and methods in Visual Basic. You end up shadowing the same
keywords in the language. To use an intrinsic language function, statement,
or method that conflicts with an assigned name, you must explicitly identify
it. Precede the intrinsic function, statement, or method name with the name
of the associated type library. For example, if you have a variable called
Left, you can only invoke the Left function using VBA.Left.

· You can't repeat names within the same level of scope. For example, you
can't declare two variables named age within the same procedure. However,
you can declare a private variable named age and a procedure-level variable
named age within the same module.

Note Visual Basic isn't case-sensitive, but it preserves the
capitalization in the statement where the name is declared.

--
Regards,
Tom Ogilvy


"John Gregory" wrote in message
...
I'm having trouble finding what's excluded from use. Is there no list of
forbidden characters? I wanted the macro names to correspond to that of

the
charts. Example "1A) MS" ... without the quotes. When that was rejected, I
assumed the bracket was the issue and rewrote to this: "1A_MS". No luck
either. So I assumed numerics as first charter were forbidden and chose:
"Chart 1A_MS". Rejected!

Help please.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Macro Names

Looking at VBA Help for the Sub statement, the "name" argument "follows
standard variable naming conventions".

Looking at VBA Help for variable definition:

Variable names must begin with an alphabetic character, must be unique
within the same scope, can't be longer than 255 characters, and can't
contain an embedded period or type-declaration character.

Type declaration characters include $ (string), # (double), % (Integer),
& (long).

Brackets delimit argument lists, so are not valid within names.

Since spaces delimit VBA tokens, a name can't contain a space character,
either.

This will work:

Chart_1A_MS


In article ,
"John Gregory" wrote:

I'm having trouble finding what's excluded from use. Is there no list of
forbidden characters? I wanted the macro names to correspond to that of the
charts. Example "1A) MS" ... without the quotes. When that was rejected, I
assumed the bracket was the issue and rewrote to this: "1A_MS". No luck
either. So I assumed numerics as first charter were forbidden and chose:
"Chart 1A_MS". Rejected!

Help please.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Tab Names in Macro Cheri Excel Discussion (Misc queries) 11 June 29th 07 01:28 AM
Macro names Natalie Excel Discussion (Misc queries) 1 March 5th 05 11:53 AM
Macro Names Douglas[_3_] Excel Programming 1 July 27th 04 05:56 PM


All times are GMT +1. The time now is 09:44 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"