![]() |
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. |
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. |
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. |
All times are GMT +1. The time now is 04:34 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com