+ Reply to Thread
Results 1 to 4 of 4

Code running v slowly when Called from another Macro

  1. #1
    Registered User
    Join Date
    03-03-2008
    Posts
    4

    Code running v slowly when Called from another Macro

    Hi there, I'm creating a game in excel - I'm pretty new to vba code writing and have come across a problem that has me stumped...

    I have some code as follows which takes approx. 30 seconds to run (ALLENEMYMOVE). However when I Call this at the end of another macro (AFTERFIGHTTOHOME) the same code now takes approx 5 mins to run. The cells altered by the (AFTERFIGHTTOHOME) macro do not affect the (ALLENEMYMOVE) macro so not sure what the difference is - if I run the two parts of code separately they execute quickly but putting them together seems to decrease the speed substantially. Any ideas why this is or how to get round this? Many thanks,

    Theo


    Please Login or Register  to view this content.
    Last edited by theo499; 02-04-2019 at 05:54 AM.

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,266

    Re: Code running v slowly when Called from another Macro

    Please use Code Tags when posting code.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    The first thing that comes to mind is that at the end of AFTERFIGHTTOHOME you calculate sheets Map.

    At the start of ALLENEMYMOVE you calculate sheets Map again. What if you remove one of them ?
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Registered User
    Join Date
    03-03-2008
    Posts
    4

    Re: Code running v slowly when Called from another Macro

    I removed one of the calculate rows and it worked! Thanks for your help! Strange I wouldn't have thought that would affect the speed of the following macro so much but seems to have done the trick - many thanks Theo

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,266

    Re: Code running v slowly when Called from another Macro

    Glad to help and thanks for rep+.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Help my code is running very slowly..
    By wishmaker in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-06-2014, 06:03 AM
  2. VBA Code is running really slowly
    By behrensf84 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-07-2014, 06:06 PM
  3. Code running really slowly
    By The Phil in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-03-2014, 08:42 PM
  4. [SOLVED] Code running slowly
    By Sweepin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-30-2013, 09:15 PM
  5. [SOLVED] Code running slowly any way of speeding up processing time
    By boomboomblock in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-02-2013, 09:09 AM
  6. Code running slowly
    By rhudgins in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 02-01-2011, 11:08 AM
  7. Paste code running extremely slowly...
    By KR in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-03-2005, 11:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1