ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Calling a procedure in a procedure (https://www.excelbanter.com/excel-programming/307279-re-calling-procedure-procedure.html)

Norman Jones

Calling a procedure in a procedure
 
Hi Alex,

I could replicate your problem if I had a module named Summary.

If this is your situation, rename either the sub or the module.

---
Regards,
Norman



"Alex" wrote in message
...
I'm getting the following error..

Compile Error:

Expected variable or procedure, not module

When I run my macro and it shows this part of my code....

Finish = MsgBox("Click YES to finish report, Click NO to end." & Chr(13) &

_
"Rerun the M & S Macro if you need to add more reports", vbYesNo +
vbInformation)
If Finish = vbYes Then
Summary '<----- THIS PART IS HIGHLIGHTED ON ERROR
Exit Sub
Else
MsgBox "Let me know if this macro has helped you."
End If

BTW I do have a variable for this though it's not here.

Any ideas why the error?




ALEX

Calling a procedure in a procedure
 
There really is nothing to the procedure SUMMARY all it is a actual recorded
macro. Nothing has been edited aside from the bloated code.


"Norman Jones" wrote:

Hi Alex,

I could replicate your problem if I had a module named Summary.

If this is your situation, rename either the sub or the module.

---
Regards,
Norman



"Alex" wrote in message
...
I'm getting the following error..

Compile Error:

Expected variable or procedure, not module

When I run my macro and it shows this part of my code....

Finish = MsgBox("Click YES to finish report, Click NO to end." & Chr(13) &

_
"Rerun the M & S Macro if you need to add more reports", vbYesNo +
vbInformation)
If Finish = vbYes Then
Summary '<----- THIS PART IS HIGHLIGHTED ON ERROR
Exit Sub
Else
MsgBox "Let me know if this macro has helped you."
End If

BTW I do have a variable for this though it's not here.

Any ideas why the error?





Norman Jones

Calling a procedure in a procedure
 
Ok, starting from the othe end, what happens if you rename your called sub
as (say) MYSummary?

Obviously, change Summary to MySummary in your calling sub!

---
Regards,
Norman



"Alex" wrote in message
...
There really is nothing to the procedure SUMMARY all it is a actual

recorded
macro. Nothing has been edited aside from the bloated code.


"Norman Jones" wrote:

Hi Alex,

I could replicate your problem if I had a module named Summary.

If this is your situation, rename either the sub or the module.

---
Regards,
Norman



"Alex" wrote in message
...
I'm getting the following error..

Compile Error:

Expected variable or procedure, not module

When I run my macro and it shows this part of my code....

Finish = MsgBox("Click YES to finish report, Click NO to end." &

Chr(13) &
_
"Rerun the M & S Macro if you need to add more reports", vbYesNo +
vbInformation)
If Finish = vbYes Then
Summary '<----- THIS PART IS HIGHLIGHTED ON

ERROR
Exit Sub
Else
MsgBox "Let me know if this macro has helped you."
End If

BTW I do have a variable for this though it's not here.

Any ideas why the error?







N10

Calling a procedure in a procedure
 

I guess that fixed It ! ?

N10 !
"Norman Jones" wrote in message
...
Ok, starting from the othe end, what happens if you rename your called sub
as (say) MYSummary?

Obviously, change Summary to MySummary in your calling sub!

---
Regards,
Norman



"Alex" wrote in message
...
There really is nothing to the procedure SUMMARY all it is a actual

recorded
macro. Nothing has been edited aside from the bloated code.


"Norman Jones" wrote:

Hi Alex,

I could replicate your problem if I had a module named Summary.

If this is your situation, rename either the sub or the module.

---
Regards,
Norman



"Alex" wrote in message
...
I'm getting the following error..

Compile Error:

Expected variable or procedure, not module

When I run my macro and it shows this part of my code....

Finish = MsgBox("Click YES to finish report, Click NO to end." &

Chr(13) &
_
"Rerun the M & S Macro if you need to add more reports", vbYesNo

+
vbInformation)
If Finish = vbYes Then
Summary '<----- THIS PART IS HIGHLIGHTED ON

ERROR
Exit Sub
Else
MsgBox "Let me know if this macro has helped you."
End If

BTW I do have a variable for this though it's not here.

Any ideas why the error?








Norman Jones

Calling a procedure in a procedure
 
Hi Alex,

What are the names of the modules in this project?

Where are the two procedures stored?

---
Regards,
Norman



"Alex" wrote in message
...
Here's what i get when I press F1 (HELP)...

Expected variable or procedure, not module


There is no variable or procedure by this name in the current scope, but
there is a module by this name. This error has the following cause and
solution:

The name of a module is used as a variable or procedure.
Check the spelling of the variable or procedure name, and make sure the

name
you want to refer to isn't private to another module. A module name can be

a
qualifier, but can't stand alone.




Chip Pearson

Calling a procedure in a procedure
 
I needed to have the SUBs in the same Module for the procedure
to procedure
call to work.


Generally speaking, this is not true. As long as the procedures
are not marked as Private, they can reside in separate modules.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Alex" wrote in message
...
I figured it out... somewhat... I have 2 different

Modules....And that was
the problem....

I needed to have the SUBs in the same Module for the procedure

to procedure
call to work.

DOH!


"Norman Jones" wrote:

Hi Alex,

What are the names of the modules in this project?

Where are the two procedures stored?

---
Regards,
Norman



"Alex" wrote in message
...
Here's what i get when I press F1 (HELP)...

Expected variable or procedure, not module


There is no variable or procedure by this name in the

current scope, but
there is a module by this name. This error has the

following cause and
solution:

The name of a module is used as a variable or procedure.
Check the spelling of the variable or procedure name, and

make sure the
name
you want to refer to isn't private to another module. A

module name can be
a
qualifier, but can't stand alone.







Norman Jones

Calling a procedure in a procedure
 
Hi Alex,

As Chip points out in the adjacent post, unless the called sub is marked as
Private, the fact that the two subs are in different modules should not pose
any problem.

Further, if the subs were marked as Private, I would expect an error message
akin to:

Sub or Function not defined

In your described scenario I would not expect your reported error.

--
Regards,
Norman



"Alex" wrote in message
...
I figured it out... somewhat... I have 2 different Modules....And that was
the problem....

I needed to have the SUBs in the same Module for the procedure to

procedure
call to work.

DOH!


"Norman Jones" wrote:

Hi Alex,

What are the names of the modules in this project?

Where are the two procedures stored?

---
Regards,
Norman



"Alex" wrote in message
...
Here's what i get when I press F1 (HELP)...

Expected variable or procedure, not module


There is no variable or procedure by this name in the current scope,

but
there is a module by this name. This error has the following cause and
solution:

The name of a module is used as a variable or procedure.
Check the spelling of the variable or procedure name, and make sure

the
name
you want to refer to isn't private to another module. A module name

can be
a
qualifier, but can't stand alone.







Norman Jones

Calling a procedure in a procedure
 
Hi Alex,

Would having the module and the sub the same name affect it?


Indeed!

In my first response to you I said:

Hi Alex,


I could replicate your problem if I had a module named Summary.


If this is your situation, rename either the sub or the module.




---
Regards,
Norman



"Alex" wrote in message
...
hhmmm...

By default all subs are public right?

Would having the module and the sub the same name affect it?


"Norman Jones" wrote:

Hi Alex,

As Chip points out in the adjacent post, unless the called sub is marked

as
Private, the fact that the two subs are in different modules should not

pose
any problem.

Further, if the subs were marked as Private, I would expect an error

message
akin to:

Sub or Function not defined

In your described scenario I would not expect your reported error.

--
Regards,
Norman



"Alex" wrote in message
...
I figured it out... somewhat... I have 2 different Modules....And that

was
the problem....

I needed to have the SUBs in the same Module for the procedure to

procedure
call to work.

DOH!


"Norman Jones" wrote:

Hi Alex,

What are the names of the modules in this project?

Where are the two procedures stored?

---
Regards,
Norman



"Alex" wrote in message
...
Here's what i get when I press F1 (HELP)...

Expected variable or procedure, not module


There is no variable or procedure by this name in the current

scope,
but
there is a module by this name. This error has the following cause

and
solution:

The name of a module is used as a variable or procedure.
Check the spelling of the variable or procedure name, and make

sure
the
name
you want to refer to isn't private to another module. A module

name
can be
a
qualifier, but can't stand alone.










Chip Pearson

Calling a procedure in a procedure
 
By default all subs are public right?

Yes.

Would having the module and the sub the same name affect it?


Yes. A module and a procedure (in any module) should never share
the same name.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Alex" wrote in message
...
hhmmm...

By default all subs are public right?

Would having the module and the sub the same name affect it?


"Norman Jones" wrote:

Hi Alex,

As Chip points out in the adjacent post, unless the called

sub is marked as
Private, the fact that the two subs are in different modules

should not pose
any problem.

Further, if the subs were marked as Private, I would expect

an error message
akin to:

Sub or Function not defined

In your described scenario I would not expect your reported

error.

--
Regards,
Norman



"Alex" wrote in message
...
I figured it out... somewhat... I have 2 different

Modules....And that was
the problem....

I needed to have the SUBs in the same Module for the

procedure to
procedure
call to work.

DOH!


"Norman Jones" wrote:

Hi Alex,

What are the names of the modules in this project?

Where are the two procedures stored?

---
Regards,
Norman



"Alex" wrote in message

...
Here's what i get when I press F1 (HELP)...

Expected variable or procedure, not module


There is no variable or procedure by this name in the

current scope,
but
there is a module by this name. This error has the

following cause and
solution:

The name of a module is used as a variable or

procedure.
Check the spelling of the variable or procedure name,

and make sure
the
name
you want to refer to isn't private to another module. A

module name
can be
a
qualifier, but can't stand alone.











All times are GMT +1. The time now is 08:14 PM.

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