+ Reply to Thread
Results 1 to 4 of 4

Which is faster? VBA code or formula in spreadsheet

  1. #1
    Registered User
    Join Date
    02-06-2014
    Location
    Austin, Texas
    MS-Off Ver
    Excel 2010
    Posts
    48

    Which is faster? VBA code or formula in spreadsheet

    As I work on a monster spreadsheet I'm putting together, I want to make sure that it does not get bogged down doing calculations and running VBA code.

    Some (if not all) of what I am working on can be done either via excel formulas in the spreadsheet or VBA code associated with the worksheet.

    Out of curiosity, do any of the excel gurus know which requires less processing time, i.e. which gets the result "faster" with less processing overhead?

    Thanks!

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Which is faster? VBA code or formula in spreadsheet

    As a general rule, native Excel formulas, because they are sourced in compiled code, are faster than VBA UDF solutions. However, there are techniques available in VBA that sometimes allow you to optimize the Excel workbook's properties during code execution to deliver faster solutions.
    Last edited by Ron Coderre; 04-09-2014 at 02:29 PM. Reason: added clarifications
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    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: Which is faster? VBA code or formula in spreadsheet

    Hi,

    Without exception it will be faster the more you leave in the workbook environment for standard functions to handle.
    Only resort to VBA as a last resort. And then if you have big ranges to handle read them into a VBA array(s) so that you handle as much as possible in the VBE. The big overhead occurs with things like loops which involve jumping backwards and forwards between the VBE and the Application in order to read/write data.
    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.

  4. #4
    Registered User
    Join Date
    02-06-2014
    Location
    Austin, Texas
    MS-Off Ver
    Excel 2010
    Posts
    48

    Re: Which is faster? VBA code or formula in spreadsheet

    Thanks to both of you!

    "The big overhead occurs with things like loops which involve jumping backwards and forwards between the VBE and the Application in order to read/write data. "

    That makes a lot of sense. I'll keep that in mind as I continue.

+ 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. Is there a faster way to read cells from another spreadsheet
    By mrall in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-01-2012, 04:46 PM
  2. Can code run faster
    By leem in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-16-2010, 02:52 PM
  3. Load multiple CSV files in a spreadsheet faster
    By grid in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-10-2010, 03:29 PM
  4. I need faster code
    By mpeplow in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-16-2007, 05:30 PM
  5. Faster way to code this
    By jhahes in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-06-2006, 12:08 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