+ Reply to Thread
Results 1 to 18 of 18

Cause and solution of slow execution of VBA!

  1. #1
    Forum Contributor meus's Avatar
    Join Date
    11-25-2014
    Location
    kathmandu
    MS-Off Ver
    2010/ 2013
    Posts
    287

    Cause and solution of slow execution of VBA!

    Hey All!!
    I have a VBA program and have couple of macros assigned to a button.. I was wondering why my Macro is slow even if it is not so lenthy..
    But while debugging i have found that code goes to "worksheet_change" frequently and the debugging takes very long time so the macro is taking time...
    But i have a question that while my macro is running, in middle of debugging, why is it going in Worksheet_change even if it doesnot have any link...
    EXAMPLE:
    Please Login or Register  to view this content.
    in the above code, after last line " Range("F2").Value = "2015 ABC corp ltd "
    it goes to another WORKSHEET_CHANGE while debugging...
    Please Login or Register  to view this content.
    not Just this, but it goes frequently in worksheet change which i think is useless......
    I dont want this... because of this my macro is taking like 3-4 secs to execute..
    Any help would be appreciate...
    Please Reply

  2. #2
    Forum Contributor
    Join Date
    09-03-2015
    Location
    IE
    MS-Off Ver
    2003 - 2016
    Posts
    258

    Re: Cause and solution of slow execution of VBA!

    Out of context it's hard to suggest based on a couple of lines of code, but you could try turning off Event handling. Not forgetting to turn it on again at the end
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor meus's Avatar
    Join Date
    11-25-2014
    Location
    kathmandu
    MS-Off Ver
    2010/ 2013
    Posts
    287

    Re: Cause and solution of slow execution of VBA!

    Yea Great! thanks for your reply.. Now it is not going to the Worksheet_Change but still the code is running very slow.. like it takes 3-4 seconds..
    Below is the code.. Please help me what can i do with the following code to make it faster..
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor meus's Avatar
    Join Date
    11-25-2014
    Location
    kathmandu
    MS-Off Ver
    2010/ 2013
    Posts
    287

    Re: Cause and solution of slow execution of VBA!

    Another thing that the code is linked up with 3-4 pivot tables....

  5. #5
    Forum Contributor
    Join Date
    09-03-2015
    Location
    IE
    MS-Off Ver
    2003 - 2016
    Posts
    258

    Re: Cause and solution of slow execution of VBA!

    After seeing the fulll code, that change wouldn't have made a big difference...

    And you're working with the slowest thing of all in Excel, pretty user interface elements. I can't really suggest anything because the code is very specific to your workbook so any changes are going to have to be made, and tested, separately.

    I would, however, go back and look at the code closely and see if everything is absolutely essential. For example
    Please Login or Register  to view this content.
    You can also rationalise the code a little. Instead of
    Please Login or Register  to view this content.
    You could use
    Please Login or Register  to view this content.
    While that's not going to shave seconds off the total time, optimise as much as possible and you might see some worthwhile gain.

  6. #6
    Forum Contributor meus's Avatar
    Join Date
    11-25-2014
    Location
    kathmandu
    MS-Off Ver
    2010/ 2013
    Posts
    287

    Re: Cause and solution of slow execution of VBA!

    Thanks.. hope to get more help from experts...

  7. #7
    Registered User
    Join Date
    02-06-2013
    Location
    Ezinge, The Netherlands
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013
    Posts
    65

    Re: Cause and solution of slow execution of VBA!

    The question is also 'why' you have this macro running in the worksheet_change event.
    Since the objects are already on the worksheet, is it really needed to have the objects updated after something has changed on worksheet?
    What are the changes on the worksheet that might need the macro, and better: what are the updates the sheet doens't need to be updated?

    If you have more insight on that, updating the worksheet might not be used that often. So for 'small' changes, place a if statement in the beginning of the function to exclude these.

    Another way is to make a button to update the GUI and have other changes corrected by the worksheet_change event.
    Maybe instead of using the worksheet_change you can use worksheet_activate? (so the sheet is updated after you switch worksheets)
    If happy with the answer, press 'Add Reputation'

  8. #8
    Forum Contributor meus's Avatar
    Join Date
    11-25-2014
    Location
    kathmandu
    MS-Off Ver
    2010/ 2013
    Posts
    287

    Re: Cause and solution of slow execution of VBA!

    I have shown my code in the above post...
    No,.. Worksheet_activate will not be possible because it is not the event that i want... The event has been stopped already.. read my above posts.......
    Just want my macro to run fast...
    thanks

  9. #9
    Forum Contributor meus's Avatar
    Join Date
    11-25-2014
    Location
    kathmandu
    MS-Off Ver
    2010/ 2013
    Posts
    287

    Re: Cause and solution of slow execution of VBA!

    Anyone has idea?? want to help me please??

  10. #10
    Forum Contributor meus's Avatar
    Join Date
    11-25-2014
    Location
    kathmandu
    MS-Off Ver
    2010/ 2013
    Posts
    287

    Re: Cause and solution of slow execution of VBA!

    ???????????????????

  11. #11
    Forum Contributor meus's Avatar
    Join Date
    11-25-2014
    Location
    kathmandu
    MS-Off Ver
    2010/ 2013
    Posts
    287

    Re: Cause and solution of slow execution of VBA!


    <BR>



  12. #12
    Forum Contributor meus's Avatar
    Join Date
    11-25-2014
    Location
    kathmandu
    MS-Off Ver
    2010/ 2013
    Posts
    287

    Re: Cause and solution of slow execution of VBA!

    ???????? No one can help me?????????

  13. #13
    Forum Contributor meus's Avatar
    Join Date
    11-25-2014
    Location
    kathmandu
    MS-Off Ver
    2010/ 2013
    Posts
    287

    Re: Cause and solution of slow execution of VBA!


  14. #14
    Forum Contributor
    Join Date
    09-03-2015
    Location
    IE
    MS-Off Ver
    2003 - 2016
    Posts
    258

    Re: Cause and solution of slow execution of VBA!

    I'm no 'expert' - but I will say you are not going to have much luck getting that to run appreciably faster.

    Thelongpants made a valid point above as to why you run this when it does not seem like it is necessary to run it and you seem to have discounted/ignored my suggestions.

    That's your perogative, of course, but you will not make many friends by peppering the board with silly posts like the last 4 or 5.

  15. #15
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Cause and solution of slow execution of VBA!

    Hi meus,

    It is difficult to debug your problem without a sample file. In general, you will get a quicker, more accurate response if you upload a sample file in addition to posting your macro that gives you problems.

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

    Lewis

  16. #16
    Forum Contributor meus's Avatar
    Join Date
    11-25-2014
    Location
    kathmandu
    MS-Off Ver
    2010/ 2013
    Posts
    287

    Re: Cause and solution of slow execution of VBA!

    Sorry if i was rude or behaved negative on board...
    I found that the source file was too heavy which leading to slow macro...
    Because that macro uses 4-5 pivot tables to filter and use slicer, it was becoming slow... I had somewhere around 40000 rows data and i deleted it to 5000 data, it was running fast.. It might be because of heavy source file + the pivots i am using...

    Thanks..

  17. #17
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Cause and solution of slow execution of VBA!

    If possible keep your file in Binary Format (.xlsb) to see better performance


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  18. #18
    Forum Contributor meus's Avatar
    Join Date
    11-25-2014
    Location
    kathmandu
    MS-Off Ver
    2010/ 2013
    Posts
    287

    Re: Cause and solution of slow execution of VBA!

    thanks...........

+ 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. [SOLVED] Simple VBA Buttons very slow in execution.
    By Kattenhove in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-09-2015, 08:36 AM
  2. Macro is running real slow and makes navigating the worksheet really slow after execution.
    By MichWolverines in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-03-2013, 04:29 PM
  3. [SOLVED] Slow Macro Execution
    By Gandalf2524 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-18-2013, 12:20 PM
  4. Slow VBA execution
    By GustavBA in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-03-2013, 06:40 AM
  5. Slow Macro execution
    By rickparker in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-29-2012, 11:16 AM
  6. Slow SUMIF() execution?
    By ahartman in forum Excel General
    Replies: 6
    Last Post: 04-09-2010, 01:21 PM
  7. Slow code execution
    By side_ in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-21-2005, 01:44 PM

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