+ Reply to Thread
Results 1 to 3 of 3

Trying to optimize VBA code for Excel 365

  1. #1
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    Trying to optimize VBA code for Excel 365

    Hi everyone,

    Like many people, I have VBA code which worked smooth and fast using Excel 2010 but slowed to a crawl when we moved to Excel 365. I'm assuming the code needs to be optimize and I'm trying to think of ways how. Below is sample code which is structurally representative of much of the macros in the workbook:

    Please Login or Register  to view this content.
    I thought perhaps there's a way to apply multiple offsets to a single Find line but i'm not sure if that's a thing. Any ideas?

    Thanks!!

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,153

    Re: Trying to optimize VBA code for Excel 365

    My proposal, although without an example of data it is difficult to find specific solutions:
    1. Early binding could be used
    2. You could improve the addressing of objects a bit - standardize them a bit
    3. Are cells "A3" and "C25" involved in calculating some values ​​"on the fly" for formulas in other cells ?
    4. Data could be loaded from a spreadsheet to memory - calculations would be faster - but see point 3, which complicates the matter
    5. You can divide the "If" conditions into two separate conditions, it should work faster

    For example:
    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Trying to optimize VBA code for Excel 365

    I've noticed the same problem (code running fine in 2010 running noticeably slower in 365). I would be very interested to learn how this could be improved.

    In regards to your sample code, I can see a few ways you could squeeze better performance out of this while still running it on a worksheet (Personally I prefer to read/write sheets twice only - read the data, process everything with an array(s) and then write it back once - this is exponentially faster. However this approach may not work for you if your code is heavily tied to the worksheets. I can't recommend this without knowing what you are doing)

    Code below. I have made comments to explain what I have changed to improve the performance.

    Please Login or Register  to view this content.
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

+ 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] Optimize Code
    By MusicMan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-17-2019, 04:01 PM
  2. optimize code if possible
    By mohadin in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-01-2019, 10:31 AM
  3. optimize code if possible
    By mohadin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-01-2019, 06:18 AM
  4. How can I optimize my code
    By viettest in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-08-2019, 05:02 PM
  5. Need to optimize the code
    By pm.patel189 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-05-2018, 01:06 PM
  6. Optimize a code
    By pezalmendra in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-06-2015, 05:31 PM
  7. Optimize code
    By miso.dca in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-08-2011, 03:35 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