+ Reply to Thread
Results 1 to 9 of 9

Help my code is running very slowly..

  1. #1
    Registered User
    Join Date
    11-12-2009
    Location
    surrey
    MS-Off Ver
    Excel 2003
    Posts
    22

    Help my code is running very slowly..

    Thank you to everyone thats helped me get this far, but I need your assistance again. Currently the following code take about 15 minutes to run through 300 lines. so any help would be greatly appreciated

    Thank you in advance. John

    Please Login or Register  to view this content.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Help my code is running very slowly..

    Difficult to comment with certainty without seeing the request in the context of its workbook but avoid a loop and consider using Autofilter to first filter the rows you're trying to update and then add the relevant formulae to the filtered rows before removing the autofilter.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Valued Forum Contributor Kamboj's Avatar
    Join Date
    09-25-2014
    Location
    India
    MS-Off Ver
    2003 - 2010
    Posts
    430

    Re: Help my code is running very slowly..

    use this command in the beginning

    Application.ScreenUpdating = False

  4. #4
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Help my code is running very slowly..

    There's nothing particularly obvious in your code that's slowing things down.

    Hard to find a good answer without seeing the workbook:

    Are there many complex / volatile formuale? I'd suggest switching calculation to manual before running your code, then switch back to automatic (if necessary) afterwards, see if that helps speed things up.

    Are there any workbook / worksheet change events being triggered by every value change? If so, try disabling application events.

    And as always, disabling screenupdating helps speed things up.


    To summarise:
    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,247

    Re: Help my code is running very slowly..

    Reading and writing cell by cell won't be quick. You can speed it up using arrays like this:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  6. #6
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Help my code is running very slowly..

    Hi.. Not tested.. but maybe the loop can be something like this..?

    Please Login or Register  to view this content.
    It probably isn't any quicker.. actually.. it may even be slower (as there is an extra loop there)..

    @Rory.. any advice on whether doing it like this is better/worse?

  7. #7
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,594

    Re: Help my code is running very slowly..

    Try this

    Please Login or Register  to view this content.
    Last edited by kvsrinivasamurthy; 10-11-2014 at 09:03 AM.

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,247

    Re: Help my code is running very slowly..

    Quote Originally Posted by apo View Post
    @Rory.. any advice on whether doing it like this is better/worse?
    I doubt it will be significantly different - there may be an additional loop and function call in there but the same amount of data has to be processed either way.

  9. #9
    Registered User
    Join Date
    11-12-2009
    Location
    surrey
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Help my code is running very slowly..

    Thank you!

    I'll check out all your suggestions and let know how I get on.

+ 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. VBA Code is running really slowly
    By behrensf84 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-07-2014, 06:06 PM
  2. Code running really slowly
    By The Phil in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-03-2014, 08:42 PM
  3. [SOLVED] Code running slowly
    By Sweepin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-30-2013, 09:15 PM
  4. Code running slowly
    By rhudgins in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 02-01-2011, 11:08 AM
  5. [SOLVED] Paste code running extremely slowly...
    By KR in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-03-2005, 11:05 AM

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