ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Module Names11 (https://www.excelbanter.com/excel-programming/357439-module-names11.html)

Sharon

Module Names11
 
Hi - I have a pile of modules in my Excel workbook. I was copying some
others from another workbook. So now I have some modules, not all, being
named "Module2.All" rather than just "All". I can't find any rename option
for the modules and of course any procedure that calls them can't find them,
nor will the procedures recognise Module2.All. If anybody has any ideas I
would be really grateful.
--
Sharon

Tom Ogilvy

Module Names11
 
in the project explorer, click on the module name in the Tree (expand the
mdule branch if necessary). Then make the properties window visible (F4 or
View=Properties Window). The property window of the Module has its name.
Highlight Module2.All and type in a new name.

--
Regards,
Tom Ogilvy


"Sharon" wrote:

Hi - I have a pile of modules in my Excel workbook. I was copying some
others from another workbook. So now I have some modules, not all, being
named "Module2.All" rather than just "All". I can't find any rename option
for the modules and of course any procedure that calls them can't find them,
nor will the procedures recognise Module2.All. If anybody has any ideas I
would be really grateful.
--
Sharon


Sharon

Module Names11
 
Hi Tom

Thanks for that. In fact the name in the properties window is showing as
Module2. The Sub is called All. So when I changed Module2 to All, it is now
seeing the module as All.All . Am I missing something (nothing new for me!).

--
Sharon


"Tom Ogilvy" wrote:

in the project explorer, click on the module name in the Tree (expand the
mdule branch if necessary). Then make the properties window visible (F4 or
View=Properties Window). The property window of the Module has its name.
Highlight Module2.All and type in a new name.

--
Regards,
Tom Ogilvy


"Sharon" wrote:

Hi - I have a pile of modules in my Excel workbook. I was copying some
others from another workbook. So now I have some modules, not all, being
named "Module2.All" rather than just "All". I can't find any rename option
for the modules and of course any procedure that calls them can't find them,
nor will the procedures recognise Module2.All. If anybody has any ideas I
would be really grateful.
--
Sharon


Tom Ogilvy

Module Names11
 
Yes. You are missing a clear explanation of your problem. You stated you
wanted to rename your module for which I gave you the correct answer.

It now appears that what you were originally talking about was what you see
in Tools=Macro=Macros where you see
Module1.All
Module2.All
And you wanted to rename your procedure so it didn't have the Module2. this
is unnecessary.

Possibly. When you imported modules into your workbook, they had duplicate
macro names. Excel adds the module designation in Tools=Macro=Macros so
you can tell which one you want to run. Selecting it and hitting run should
cause no problem.

In the case of the module you renamed, you should change the module name
back to module2 or something unique. You should not have a Sub named the
same as the module name. If you want to rename your subs/procedures, just
edit their declaration in the module. (but this should not be necessary)

Sub MyMacro()

End sub

would be renamed by changing MyMacro to something else.

Your statement that Module2.All doesn't work is incorrect. As an example,

Module1:
Sub EFG()
MsgBox "In Module1"
End Sub

Module2:
Sub EFG()
MsgBox "In Module2"
End Sub

Sub ABB()
Module2.EFG
Module1.EFG
End Sub

When I run ABB, it first executes the EFG in Module2, then it executes the
EFG in Module1.

However, since ABB is in Module2,

Sub ABB()
EFG
Module1.EFG
End Sub

Works exactly the same since it look at its own module first.

For procedures with duplicate names, if they are external to the module of
the calling procedure, they should include the module name.

--
Regards,
Tom Ogilvy





"Sharon" wrote:

Hi Tom

Thanks for that. In fact the name in the properties window is showing as
Module2. The Sub is called All. So when I changed Module2 to All, it is now
seeing the module as All.All . Am I missing something (nothing new for me!).

--
Sharon


"Tom Ogilvy" wrote:

in the project explorer, click on the module name in the Tree (expand the
mdule branch if necessary). Then make the properties window visible (F4 or
View=Properties Window). The property window of the Module has its name.
Highlight Module2.All and type in a new name.

--
Regards,
Tom Ogilvy


"Sharon" wrote:

Hi - I have a pile of modules in my Excel workbook. I was copying some
others from another workbook. So now I have some modules, not all, being
named "Module2.All" rather than just "All". I can't find any rename option
for the modules and of course any procedure that calls them can't find them,
nor will the procedures recognise Module2.All. If anybody has any ideas I
would be really grateful.
--
Sharon



All times are GMT +1. The time now is 02:55 AM.

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