ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Naming a Macro with a Letter (https://www.excelbanter.com/excel-discussion-misc-queries/22534-naming-macro-letter.html)

Carol

Naming a Macro with a Letter
 
I have saved a series of macros to use in a workbook, but Excel will not
allow me to name a macro "C." I have used lots of other letters with no
problem, but when I name a macro "C" it tells me that it is an invalid name.
Is there any way around this? If not, what is the reasoning behind it? Any
help will be greatly appreciated. Thanks!

Dave Peterson

I use xl2003 and I could name a macro "C".

But I couldn't run it via tools|macro|macros...

I could write if I specified the module it was in (just typing: module1.c, then
clicking Run was sufficient).

In fact, if I created a sub named C in two different modules (module1.c and
module2.c), then I could even just point at the macro I wanted to run and click
run.

But if I typed in that "module1.c" and tried to give it a nice shortcut under
the Options button on that dialog, I had more trouble.

I got an error message when I tried to use that shortcut:
"The macro 'A:A' cannot be found."

Which gives a hint why you shouldn't use the letter C as a name for a macro.

I think excel wants you to avoid anything that looks like a range reference.
Try naming a macro A1 and you get the same problem.

If you've ever used xl in R1C1 reference style mode, you'll see that C is used
to indicate the column. Excel can get confused so it doesn't want you to use
that character as a macro name.

The same kind of thing happens if you try to give a range a name that looks like
it could be a reference. (And excel is more conservative--even if it can't be a
range, excel will still put the kybash on it if it looks like it has the same
format.)



Carol wrote:

I have saved a series of macros to use in a workbook, but Excel will not
allow me to name a macro "C." I have used lots of other letters with no
problem, but when I name a macro "C" it tells me that it is an invalid name.
Is there any way around this? If not, what is the reasoning behind it? Any
help will be greatly appreciated. Thanks!


--

Dave Peterson

Dave Peterson

I could write if I specified the module it was in (just typing: module1.c, then
clicking Run was sufficient).

should have been:

I could run it if I specified the module it was in (just typing: module1.c,
then clicking Run was sufficient).

<<snipped


All times are GMT +1. The time now is 07:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com