Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Called macro runs twice in excel 2002

what fires the original macro? Is it tied to an event? I would put a
msgbox in the original macro just before the run command and see if the
original macro is running twice as well.

--
Regards,
Tom Ogilvy

"Martin French" wrote in message
...
Hi Everyone. This one really has me stumped but I'm sure
the answer is dead simple. I have written a macro in one
spreadsheet which then calls a macro from another. The
control then passes back to the original macro. It was
created in XL97 under windows98SE. My machine has now been
upgraded to XP and XL2002. When I run the macro now, it
runs the called procedure twice before returning to the
original coding. Does anyone know why this happens and is
there a way to stop it?

I have simplified the code for the purpose of
demonstrating this unusual behaviour.
The line of code in the main macro which calls the
secondary macro is:

application.run "2ndplacedatabase_sept_2003.xls!dummymacro
()"
End

The code in the secondary sheet is:

Sub dummymacro()
MsgBox "Now in the dummy macro"
End Sub

When I run this simple code the message box in the
secondary macro appears twice before control passes back
to the main macro.

Many Thanks to anyone who can help



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Called macro runs twice in excel 2002

Good catch - I can reproduce it in xl2000 as well. I can't say why either.

--
Regards,
Tom Ogilvy

"Andy Pope" wrote in message
...
Hi Tom,

I can generate the problem and solution with two very simple macros, in
the same workbook.

Sub A
MsgBox "Sub A"
End Sub
Sub B
Application.Run "A()"
End Sub

If you remove the open and close brackets all works as expected.
i.e.
Sub B
Application.Run "A"
End Sub

Trouble is I do not know why.

Tom Ogilvy wrote:

what fires the original macro? Is it tied to an event? I would put a
msgbox in the original macro just before the run command and see if the
original macro is running twice as well.


--

Cheers
Andy

http://www.andypope.info



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
VBA macro runs fine, but freezes if I try to do ANYTHING else whileit runs Rruffpaw Setting up and Configuration of Excel 1 September 17th 11 01:25 PM
Excel Macro runs fine, but freezes if I try to do ANYTHING else whileit's running Rruffpaw Setting up and Configuration of Excel 0 August 3rd 11 08:31 PM
Excel macro in 2007 runs extremely slow Acie Excel Discussion (Misc queries) 3 March 3rd 09 04:22 PM
How to change the macro called by an add in from older excel? Ian Excel Discussion (Misc queries) 2 June 25th 08 10:53 PM
One macro runs then it auto runs another macro PG Excel Discussion (Misc queries) 2 September 1st 06 09:30 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"