+ Reply to Thread
Results 1 to 5 of 5

Speed up sumproduct for large data range

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Speed up sumproduct for large data range

    I am currently using sum product as the code suggests
    =IF(E2="NA","",SUMPRODUCT((E:E<E2)*(G2=G:G))+1)
    This works fine for what I want, but I have over 200,000 rows of data. Is there any improvements of alternatives Ican make to my code to quicken things up?

    Basically I am ranking what is in column E - (based on the criteria in G) - unless in E is NA which then returns a blank cell for that row

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,462

    Re: Speed up sumproduct for large data range

    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

  3. #3
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Re: Speed up sumproduct for large data range

    I have a "cut down" example attached. Column H (highlighted) shows my existing code. I only have 300 odd rows in the example and the calculation still takes around 10 seconds.

    The full data set has over 200,000 rows - which is why I ask if the formula can be improved or altered to speed things up
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: Speed up sumproduct for large data range

    Quote Originally Posted by cmb80 View Post
    I am currently using sum product as the code suggests
    =IF(E2="NA","",SUMPRODUCT((E:E<E2)*(G2=G:G))+1)
    This works fine for what I want, but I have over 200,000 rows of data. Is there any improvements of alternatives Ican make to my code to quicken things up?
    First, get out of the habit of specifying whole-column ranges like E:E and G:G. In Excel 2007 and later, that causes SUMPRODUCT to process arrays of 1,048,576 elements. So at a minimum, change the formula to:

    =IF(E2="NA","",SUMPRODUCT(($E$1:$E$300000<E2)*(G2=$G$1:$G$300000))+1)

    Change 300000 appropriately. Also change $1 to $2 if appropriate (small detail).

    Second, if you do not require XL2003 compatibility (not saving to "xls" file), use COUNTIFS as follows:

    =IF(E2="NA","",COUNTIFS($E$1:$E$300000,"<"&E2,$G$1:$G$300000,G2)+1)

    Quote Originally Posted by cmb80 View Post
    Basically I am ranking what is in column E - (based on the criteria in G) - unless in E is NA which then returns a blank cell for that row
    FYI, I have not given any thought to whether there is a better way to do this. I suspect there is.

  5. #5
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Re: Speed up sumproduct for large data range

    Thanks, I will give that a go

+ 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. Large data sheet speed issues.
    By bone7890 in forum Excel General
    Replies: 11
    Last Post: 06-02-2014, 05:42 PM
  2. Replies: 1
    Last Post: 04-02-2011, 06:39 AM
  3. Speed of copying in large spreadsheets
    By mpalmi1037 in forum Excel General
    Replies: 0
    Last Post: 03-31-2009, 05:45 PM
  4. Large .csv file VBA speed
    By vwgolfman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-17-2007, 01:25 PM
  5. Problem with speed of PasteSpecial for large ranges
    By xlb in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-20-2005, 09:06 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