Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default Call to Re-Named Module [to match Sub() name] fails ?

I have a module name question?

When I Right click; View Code" on the worksheet, In the top left is
(Project VBA Project) window; at the bottom I have a "Modules" folder and
in there I have 4 modules. 2 of which I seemed to have renamed and not yet
seeing a problem.

However, in the last module Module3 Its intended to be a sub module;
called by the worksheet module from 2 different points. *All curently runs
fine*.

The sub routing was created with the following name:
... Sub ReBuildProgramSummary(Optional Confirm As Boolean = True)
.... code...

From the Worksheet View Code, I call this sub routine with the following
command:
'------------------------------------------------------------------------
' [default/Changed!] Button - Re-Build Program Summary Template
'------------------------------------------------------------------------
If Target.Address = "$K$1" And ActiveSheet.Name < _
srcProgramSummaryTemplateWs.Name Then
ReBuildProgramSummary True '<--- 1 -----
Range("K1").Value = "default"
End If
----------------------
All of this works fine

Now, when I have this ReBuildProgramSummary sub routine selected, in
bottom left of this screen is a Properties Module3; it has a select
button below this with Module3 Module the only option, and below this on
the Alphabetic Tab is:
(Name) Module3.

When I try to change the (Name) field from Module3 to
ReBuildProgramSummary, the
[ Compile Error - Expected variable or procedure, not module ]
at the <----1 call above.

Can I not change this (Name) field name to match?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Call to Re-Named Module [to match Sub() name] fails ?

You could change the name to match but it is not really recommended as
it causes just this type of problem. Bear in mind that a module simply
holds procedures and functions. It could hold a number of each. The name
of the module therefore is not key until you rename it to the same name
as a function. This is different for a Class Module where the name is
the actual class (object) that you are creating.

In your situation if you really want to rename the module the same as
the procedure then you would have to make this clear to your calling
code eg:

If Target.Address = "$K$1" And ActiveSheet.Name < _
srcProgramSummaryTemplateWs.Name Then
ReBuildProgramSummary.ReBuildProgramSummary True
Range("K1").Value = "default"
End If

Hope this helps
Rowan

CRayF wrote:
I have a module name question?

When I Right click; View Code" on the worksheet, In the top left is
(Project VBA Project) window; at the bottom I have a "Modules" folder and
in there I have 4 modules. 2 of which I seemed to have renamed and not yet
seeing a problem.

However, in the last module Module3 Its intended to be a sub module;
called by the worksheet module from 2 different points. *All curently runs
fine*.

The sub routing was created with the following name:
.. Sub ReBuildProgramSummary(Optional Confirm As Boolean = True)
... code...

From the Worksheet View Code, I call this sub routine with the following
command:
'------------------------------------------------------------------------
' [default/Changed!] Button - Re-Build Program Summary Template
'------------------------------------------------------------------------
If Target.Address = "$K$1" And ActiveSheet.Name < _
srcProgramSummaryTemplateWs.Name Then
ReBuildProgramSummary True '<--- 1 -----
Range("K1").Value = "default"
End If
----------------------
All of this works fine

Now, when I have this ReBuildProgramSummary sub routine selected, in
bottom left of this screen is a Properties Module3; it has a select
button below this with Module3 Module the only option, and below this on
the Alphabetic Tab is:
(Name) Module3.

When I try to change the (Name) field from Module3 to
ReBuildProgramSummary, the
[ Compile Error - Expected variable or procedure, not module ]
at the <----1 call above.

Can I not change this (Name) field name to match?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default Call to Re-Named Module [to match Sub() name] fails ?

So in my case, the external sub I created :
Sub ReBuildProgramSummary(Optional Confirm As Boolean = True)
Was placed in Module3. If over change I end up with others Is there a way
to identify the Sub() by name or do you have to remember it was in Module3?
(I may be missing something elementary here but I am very new to this VBA.


"Rowan" wrote:

You could change the name to match but it is not really recommended as
it causes just this type of problem. Bear in mind that a module simply
holds procedures and functions. It could hold a number of each. The name
of the module therefore is not key until you rename it to the same name
as a function. This is different for a Class Module where the name is
the actual class (object) that you are creating.

In your situation if you really want to rename the module the same as
the procedure then you would have to make this clear to your calling
code eg:

If Target.Address = "$K$1" And ActiveSheet.Name < _
srcProgramSummaryTemplateWs.Name Then
ReBuildProgramSummary.ReBuildProgramSummary True
Range("K1").Value = "default"
End If

Hope this helps
Rowan

CRayF wrote:
I have a module name question?

When I Right click; View Code" on the worksheet, In the top left is
(Project VBA Project) window; at the bottom I have a "Modules" folder and
in there I have 4 modules. 2 of which I seemed to have renamed and not yet
seeing a problem.

However, in the last module Module3 Its intended to be a sub module;
called by the worksheet module from 2 different points. *All curently runs
fine*.

The sub routing was created with the following name:
.. Sub ReBuildProgramSummary(Optional Confirm As Boolean = True)
... code...

From the Worksheet View Code, I call this sub routine with the following
command:
'------------------------------------------------------------------------
' [default/Changed!] Button - Re-Build Program Summary Template
'------------------------------------------------------------------------
If Target.Address = "$K$1" And ActiveSheet.Name < _
srcProgramSummaryTemplateWs.Name Then
ReBuildProgramSummary True '<--- 1 -----
Range("K1").Value = "default"
End If
----------------------
All of this works fine

Now, when I have this ReBuildProgramSummary sub routine selected, in
bottom left of this screen is a Properties Module3; it has a select
button below this with Module3 Module the only option, and below this on
the Alphabetic Tab is:
(Name) Module3.

When I try to change the (Name) field from Module3 to
ReBuildProgramSummary, the
[ Compile Error - Expected variable or procedure, not module ]
at the <----1 call above.

Can I not change this (Name) field name to match?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Call to Re-Named Module [to match Sub() name] fails ?

You would have to remember where you put each sub if you want to edit
them. If you do not have any ambiguous naming then you don't have to use
the module name when referencing a procudure in code so you can just use
Call ReBuildProgramSummary True rather than
Call Module3.ReBuildProgramSummary True

When you open a module window the Prodedure drop down, Top Right, has a
list of all procedures and functions that are sored in that module.
Selecting one from this dropdown will take the cursor to the first line
of that procedure.

Regards
Rowan

CRayF wrote:
So in my case, the external sub I created :
Sub ReBuildProgramSummary(Optional Confirm As Boolean = True)
Was placed in Module3. If over change I end up with others Is there a way
to identify the Sub() by name or do you have to remember it was in Module3?
(I may be missing something elementary here but I am very new to this VBA.


"Rowan" wrote:


You could change the name to match but it is not really recommended as
it causes just this type of problem. Bear in mind that a module simply
holds procedures and functions. It could hold a number of each. The name
of the module therefore is not key until you rename it to the same name
as a function. This is different for a Class Module where the name is
the actual class (object) that you are creating.

In your situation if you really want to rename the module the same as
the procedure then you would have to make this clear to your calling
code eg:

If Target.Address = "$K$1" And ActiveSheet.Name < _
srcProgramSummaryTemplateWs.Name Then
ReBuildProgramSummary.ReBuildProgramSummary True
Range("K1").Value = "default"
End If

Hope this helps
Rowan

CRayF wrote:

I have a module name question?

When I Right click; View Code" on the worksheet, In the top left is
(Project VBA Project) window; at the bottom I have a "Modules" folder and
in there I have 4 modules. 2 of which I seemed to have renamed and not yet
seeing a problem.

However, in the last module Module3 Its intended to be a sub module;
called by the worksheet module from 2 different points. *All curently runs
fine*.

The sub routing was created with the following name:
.. Sub ReBuildProgramSummary(Optional Confirm As Boolean = True)
... code...

From the Worksheet View Code, I call this sub routine with the following
command:
'------------------------------------------------------------------------
' [default/Changed!] Button - Re-Build Program Summary Template
'------------------------------------------------------------------------
If Target.Address = "$K$1" And ActiveSheet.Name < _
srcProgramSummaryTemplateWs.Name Then
ReBuildProgramSummary True '<--- 1 -----
Range("K1").Value = "default"
End If
----------------------
All of this works fine

Now, when I have this ReBuildProgramSummary sub routine selected, in
bottom left of this screen is a Properties Module3; it has a select
button below this with Module3 Module the only option, and below this on
the Alphabetic Tab is:
(Name) Module3.

When I try to change the (Name) field from Module3 to
ReBuildProgramSummary, the
[ Compile Error - Expected variable or procedure, not module ]
at the <----1 call above.

Can I not change this (Name) field name to match?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Call to Re-Named Module [to match Sub() name] fails ?

This may help:
http://www.cpearson.com/excel/codemods.htm


CRayF wrote:
So in my case, the external sub I created :
Sub ReBuildProgramSummary(Optional Confirm As Boolean = True)
Was placed in Module3. If over change I end up with others Is there a way
to identify the Sub() by name or do you have to remember it was in Module3?
(I may be missing something elementary here but I am very new to this VBA.


"Rowan" wrote:


You could change the name to match but it is not really recommended as
it causes just this type of problem. Bear in mind that a module simply
holds procedures and functions. It could hold a number of each. The name
of the module therefore is not key until you rename it to the same name
as a function. This is different for a Class Module where the name is
the actual class (object) that you are creating.

In your situation if you really want to rename the module the same as
the procedure then you would have to make this clear to your calling
code eg:

If Target.Address = "$K$1" And ActiveSheet.Name < _
srcProgramSummaryTemplateWs.Name Then
ReBuildProgramSummary.ReBuildProgramSummary True
Range("K1").Value = "default"
End If

Hope this helps
Rowan

CRayF wrote:

I have a module name question?

When I Right click; View Code" on the worksheet, In the top left is
(Project VBA Project) window; at the bottom I have a "Modules" folder and
in there I have 4 modules. 2 of which I seemed to have renamed and not yet
seeing a problem.

However, in the last module Module3 Its intended to be a sub module;
called by the worksheet module from 2 different points. *All curently runs
fine*.

The sub routing was created with the following name:
.. Sub ReBuildProgramSummary(Optional Confirm As Boolean = True)
... code...

From the Worksheet View Code, I call this sub routine with the following
command:
'------------------------------------------------------------------------
' [default/Changed!] Button - Re-Build Program Summary Template
'------------------------------------------------------------------------
If Target.Address = "$K$1" And ActiveSheet.Name < _
srcProgramSummaryTemplateWs.Name Then
ReBuildProgramSummary True '<--- 1 -----
Range("K1").Value = "default"
End If
----------------------
All of this works fine

Now, when I have this ReBuildProgramSummary sub routine selected, in
bottom left of this screen is a Properties Module3; it has a select
button below this with Module3 Module the only option, and below this on
the Alphabetic Tab is:
(Name) Module3.

When I try to change the (Name) field from Module3 to
ReBuildProgramSummary, the
[ Compile Error - Expected variable or procedure, not module ]
at the <----1 call above.

Can I not change this (Name) field name to match?


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
Excel fails to update call to user-written function. Jim Luedke New Users to Excel 9 August 28th 09 12:46 AM
Button fails to call macro when open an Excel via Intranet tigertax Excel Discussion (Misc queries) 1 April 12th 05 10:21 AM
MoveAfterReturn command fails in Worksheet module quartz[_2_] Excel Programming 1 April 1st 05 08:49 PM
.ONACTION macro call fails Wayne Excel Discussion (Misc queries) 2 March 2nd 05 05:10 PM
call to WorksheetFunction fails in 2003 Alex T Excel Programming 5 September 27th 03 04:26 PM


All times are GMT +1. The time now is 11:47 PM.

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"