+ Reply to Thread
Results 1 to 6 of 6

Speed test: VBA vs. Formulae?

Hybrid View

  1. #1
    Registered User
    Join Date
    12-09-2010
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    21

    Speed test: VBA vs. Formulae?

    Hi all,

    Short version - Is a VBA script liable to be quicker than multiple, heavy SumProduct formulae that take ~30 seconds to recalculate every time I ask them to look at different data?

    Less short version - I currently have a behemoth of a spreadsheet, containing lots and lots of data. Sitting on top of this, I have a dashboard that is fed by a series of dynamic SumProduct formulae - the data which it selects being togglable by a series of drop-down menus. Ostensibly, it's quite nice and does its job very well. Unfortunately, it takes quite some time for the SumProduct formulae to recalculate whenever a new data set is selected.

    A friend of mine suggested that I consider writing a VBA script to do the work instead. So, before I spend a couple of days actually going ahead and doing this, I wanted to get a general consensus on whether or not people actually think it'd be any faster.

    Any ideas, folks?

    Cheers,
    S

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,423

    Re: Speed test: VBA vs. Formulae?

    SUMIF and SUMIFS (and COUNTIF/COUNTIFS) are much quicker than using SUMPRODUCT, particularly on large arrays. You can often concatenate ranges together and then just do one comparison with SUMIF to speed things up, depending on the complexity of your SP formulae.

    Can you post a few examples?

    Pete

  3. #3
    Forum Contributor
    Join Date
    12-28-2011
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    280

    Re: Speed test: VBA vs. Formulae?

    A Pivot table approach would be an obvious solution

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Speed test: VBA vs. Formulae?

    VBA is rarely faster than inbuilt functions.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Registered User
    Join Date
    03-30-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Speed test: VBA vs. Formulae?

    Answer: As the friend with the spreadsheet, I can now say this is solved. A combination of COUNTIFS and SUMIFS ended up taking the calculation time down from 2min+ to under 1sec.

  6. #6
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,423

    Re: Speed test: VBA vs. Formulae?

    Well, that's good to hear - well done.

    One thing to consider is that those functions weren't available in Excel 2003 and earlier versions, so if you distribute the file to users with earlier versions then they will cause errors for them.

    Pete

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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