ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro calling another Macro (https://www.excelbanter.com/excel-programming/331115-macro-calling-another-macro.html)

William Benson

Macro calling another Macro
 
I did not get an answer that worked for me in an earlier post, am trying
again - if someone can figure out what is wrong I would really appreciate
it:

I have a subprocedure shown below, in a module which is named CharStats, in
Personal.xls:

Public Sub FindChar()
frmFindCharacters.Show
End Sub

I want the click event of command button on a sheet in another open workbook
to call it, and wrote:

Private Sub CommandButton1_Click()
Application.Run "Personal.xls!FindChar"
End Sub

I am getting an error message saying : "The macro 'Personal.xls!FindChar'
cannot be found.

Pls help, thanks.

"K Dales" wrote in message
...
A sub to be Public to be used by any other module:
Public Sub OtherMacro()

"William Benson" wrote:

I have a command button on Sheet1
the click event says
application.run "personal.xls!OtherMacro"

The called macro is in a code module named "MyModule" in personal.xls. It
is
declared as
Sub OtherMacro()

I am getting an application error every time the click event fires, any
ideas? TIA ... Bill







Damien McBain[_2_]

Macro calling another Macro
 
"William Benson" wrote in message
...
I did not get an answer that worked for me in an earlier post, am trying
again - if someone can figure out what is wrong I would really appreciate
it:

I have a subprocedure shown below, in a module which is named CharStats,
in Personal.xls:

Public Sub FindChar()
frmFindCharacters.Show
End Sub

I want the click event of command button on a sheet in another open
workbook to call it, and wrote:

Private Sub CommandButton1_Click()
Application.Run "Personal.xls!FindChar"
End Sub

I am getting an error message saying : "The macro 'Personal.xls!FindChar'
cannot be found.


How bout

FindChar

and shange the sub to just plain sub not private sub

I'm not much of a techo but thats how I call other subroutines



Tom Ogilvy

Macro calling another Macro
 
I copied your code from your posting and renamed the module in personal.xls
to CharStats. Created a Userform in Personal.xls named frmFindCharacters.
Added a commandbutton1 in another workbook and pasted your event code there.
It worked fine for me.

--
Regards,
Tom Ogilvy

"William Benson" wrote in message
...
I did not get an answer that worked for me in an earlier post, am trying
again - if someone can figure out what is wrong I would really appreciate
it:

I have a subprocedure shown below, in a module which is named CharStats,

in
Personal.xls:

Public Sub FindChar()
frmFindCharacters.Show
End Sub

I want the click event of command button on a sheet in another open

workbook
to call it, and wrote:

Private Sub CommandButton1_Click()
Application.Run "Personal.xls!FindChar"
End Sub

I am getting an error message saying : "The macro 'Personal.xls!FindChar'
cannot be found.

Pls help, thanks.

"K Dales" wrote in message
...
A sub to be Public to be used by any other module:
Public Sub OtherMacro()

"William Benson" wrote:

I have a command button on Sheet1
the click event says
application.run "personal.xls!OtherMacro"

The called macro is in a code module named "MyModule" in personal.xls.

It
is
declared as
Sub OtherMacro()

I am getting an application error every time the click event fires, any
ideas? TIA ... Bill










All times are GMT +1. The time now is 06:22 AM.

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