+ Reply to Thread
Results 1 to 10 of 10

Replacement VBA for sumif on a large set of data - taking too long to calcuate

  1. #1
    Forum Contributor
    Join Date
    11-07-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    126

    Replacement VBA for sumif on a large set of data - taking too long to calcuate

    Hi all,

    I have a VBA code that runs a lot of formulas and variables over a large set of data (over 50k rows). When I have gone to run the formula it is taking around 10minutes to complete each time, through process of elimination (commenting out segments of coding bits at a time) I have deduced that it is the following code that is slowing it down which uses sumif formulas.

    Please Login or Register  to view this content.

    I have searched through the forum and have found some helpful threads which replace the sumif formulas with different coding (scripting dictionaries etc) but, my VBA knowledge is intermediate at best and I am struggling to understand the coding, I wondered if anyone could help me implement this into my code to speed the VBA and whilst explaining the coding at the same time so I know what it is doing for future reference?

    TIA
    Last edited by elleb; 04-21-2020 at 12:03 PM.

  2. #2
    Valued Forum Contributor Eastw00d's Avatar
    Join Date
    02-29-2020
    Location
    Breda, NL
    MS-Off Ver
    2016, 2019
    Posts
    833

    Re: Replacement VBA for sumif on a large set of data - taking too long to calcuate

    Maybe this makes a little difference:
    Please Login or Register  to view this content.
    Cheers
    Erwin
    I started learning VBA because I was lazy ...
    Still developing.... being more lazy...

  3. #3
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,541

    Re: Replacement VBA for sumif on a large set of data - taking too long to calcuate

    I assume you are a little mixed up
    ActiveCell.FormulaR1C1 = "=SUMIF(C18,RC19,C11)"
    C18 is Row 18 and Column 3
    RC19 is Row 19 and Column 471
    C11 is Row 11 and Column 3

    I am nearly 100 percent convinced that you don't mean to reference the 471st Column.

    En Erwin zit op het Havermarktje en had dat nog niet in de gaten.

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,112

    Re: Replacement VBA for sumif on a large set of data - taking too long to calcuate

    Those are R1C1 references, not A1 references, so C18 is column R and RC19 is column S on the same row as the formula.

  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,541

    Re: Replacement VBA for sumif on a large set of data - taking too long to calcuate

    I thought that you could not mix R1C1 references with A1 references. I also got mixed up with it being a formula, no double quotes.
    My apologies to Erwin also. I "accused" him of having a beer at the entertainment center in his home town.

  6. #6
    Valued Forum Contributor Eastw00d's Avatar
    Join Date
    02-29-2020
    Location
    Breda, NL
    MS-Off Ver
    2016, 2019
    Posts
    833

    Re: Replacement VBA for sumif on a large set of data - taking too long to calcuate

    Unfortunately the bars on the Havermarkt are closed in these days ....
    besides that, I was using only the formulas of the OP, and knew that these were relative.

    Cheers
    Erwin

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,588

    Re: Replacement VBA for sumif on a large set of data - taking too long to calcuate

    elleb,

    Only guess from your code.
    If you upload a small set of data and the result, I can test it.

    Please attach a sample workbook (not a picture or pasted copy). 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 then scroll down to Manage Attachments to open the upload window.
    Please Login or Register  to view this content.
    Last edited by jindon; 04-20-2020 at 05:36 AM.

  8. #8
    Forum Contributor
    Join Date
    11-07-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    126
    Hi all,

    Thanks for the responses, I am having electrical/connectivity issues at the moment so cannot get onto the laptop to test.

    As soon as I can get back online I'll get back to you all 😁

    Thank you again

  9. #9
    Forum Contributor
    Join Date
    11-07-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    126

    Re: Replacement VBA for sumif on a large set of data - taking too long to calcuate

    Hi all,

    I've managed to get online and test the last coding, it now takes seconds to complete rather than minutes so I really appreciate all the help you've provided.

    Jindon, this might not be possible but, would you be able to explain the coding to me a little so that I can learn/understand it as I need to add another two columns (they will be in V2 and with similar formulas and I am not sure how to include them in the VBA. I'd really appreciate it as its an excellent piece of code!
    Last edited by elleb; 04-21-2020 at 12:41 PM.

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,588

    Re: Replacement VBA for sumif on a large set of data - taking too long to calcuate

    Quote Originally Posted by elleb View Post
    Jindon, this might not be possible but, would you be able to explain the coding to me a little so that I can learn/understand it as I need to add another two columns (they will be in V2 and with similar formulas and I am not sure how to include them in the VBA. I'd really appreciate it as its an excellent piece of code!
    As I mentioned, I just coded based on your code, so I don't fully understand the data structure etc.
    If you upload a small sample workbook with before/after, it would help.

+ 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. Replies: 32
    Last Post: 03-29-2024, 07:01 PM
  2. [SOLVED] Excel Formula in Large File Taking Too Long to Process
    By ziggyztz in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-29-2019, 01:02 PM
  3. Replies: 1
    Last Post: 01-24-2015, 08:29 PM
  4. [SOLVED] =IF and =SUMIF formulas creating long long long data processing times.
    By comp in forum Excel Programming / VBA / Macros
    Replies: 32
    Last Post: 03-26-2014, 02:59 PM
  5. Large Data Replacement
    By tconnell1965 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-21-2013, 02:39 PM
  6. Optimizing Formulas - taking too long to calculate large worksheet
    By lightsandsirens in forum Excel General
    Replies: 0
    Last Post: 08-21-2012, 10:38 AM
  7. Better way to transfer data my way taking a long time
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-06-2011, 06:03 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