ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro (Modle) naming insight (https://www.excelbanter.com/excel-programming/417491-macro-modle-naming-insight.html)

pgarcia

Macro (Modle) naming insight
 
Hello all,
As you know, I'm new to VB coding and I had a question about modles with
names. How do they work? I changed a name on a modle so I can find it easly
in a list of modles, but it did not work after that and if I "Call" another
modle (macro) it also did not work.

Thanks

Jim Thomlinson

Macro (Modle) naming insight
 
Do you mean Modules?
--
HTH...

Jim Thomlinson


"pgarcia" wrote:

Hello all,
As you know, I'm new to VB coding and I had a question about modles with
names. How do they work? I changed a name on a modle so I can find it easly
in a list of modles, but it did not work after that and if I "Call" another
modle (macro) it also did not work.

Thanks


pgarcia

Macro (Modle) naming insight
 
Opps, sorry, yes please.

"Jim Thomlinson" wrote:

Do you mean Modules?
--
HTH...

Jim Thomlinson


"pgarcia" wrote:

Hello all,
As you know, I'm new to VB coding and I had a question about modles with
names. How do they work? I changed a name on a modle so I can find it easly
in a list of modles, but it did not work after that and if I "Call" another
modle (macro) it also did not work.

Thanks


Jim Thomlinson

Macro (Modle) naming insight
 
Naming your modules if a very good practice to get into. At allows you to
organize your code which makes it a lot easier to maintain. Try to give your
modules descriptive names so that you know what is in them...

One nice thing about naming your modules is that you gain intellisence drop
downs. Try this... name a new module modNew and add the following procedures.

'*******************
public sub MyPublicSub()
msgbox "Tada"
call MyPrivateSub
end sub

private sub MyPrivateSub()
msgbox "Scooby Doo"
end sub
'*******************

Now in another module or sheet type
modnew.

You should get an intellisence drop down including MyPublicSub but not
MyPrivateSub. You do not necessarily need to specify the module where your
procedure is. If you just typed
Call MyPublicSub
then the compiler will search the module or object you are in. If it is not
found then it will look in other modules. If it does not exist elsewhere then
you will get an error message. If it is elsewhere but declared private then
it will not be found. If it is in two or more modules then you will get an
ambiguious call error.

I try to include the module name in my call. It self documents the code and
keeps me from spelling / typing things wrong. It also ensures that the scope
of my procedures is correct and avoid ambiguious calls.
--
HTH...

Jim Thomlinson


"pgarcia" wrote:

Opps, sorry, yes please.

"Jim Thomlinson" wrote:

Do you mean Modules?
--
HTH...

Jim Thomlinson


"pgarcia" wrote:

Hello all,
As you know, I'm new to VB coding and I had a question about modles with
names. How do they work? I changed a name on a modle so I can find it easly
in a list of modles, but it did not work after that and if I "Call" another
modle (macro) it also did not work.

Thanks



All times are GMT +1. The time now is 05:21 AM.

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