Call a macro in anothe file

W

William Benson

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
 
W

William Benson

This sub is in a module called CharStats, in Personal.xls:

Public Sub FindChar()
frmFindCharacters.Show
End Sub

This is the click event of command button on a sheet in another open file:

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

This is the error message I am getting: The macro 'Personal.xls!FindChar'
cannot be found.

Any help?
 
P

Philippe Léveillé

Try this:

1. Insert a module in the workbook where your button is; (VBE, insert,
module)
2. Copy the code from your Personal.xls to this module;
3. Go in the sheet where you have the button (right-click reassign
macro, and point to the one in your workbook)
4. ... Good Luck

Philippe Léveillé
 
T

Tom Ogilvy

Reproduced the situation you describe and it worked fine for me.

xl2003, but I wouldn't expect it to be different in other versions.
 
W

William Benson

I had it declared twice, in separate modules. Why the %$#$^$%$ can't Excel
just say so!

Sorry Tom/Philippe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top