+ Reply to Thread
Results 1 to 8 of 8

Speed up vba formula efficiently

  1. #1
    Forum Contributor
    Join Date
    06-30-2014
    Location
    London, England
    MS-Off Ver
    365 & 2010
    Posts
    107

    Speed up vba formula efficiently

    Hi,

    I hope someone can help me but I have the below code that calculates overdue days by using the NETWORKDAYS formula.

    Please Login or Register  to view this content.
    It works but the problem is that there are times I can have over 15000 rows and it takes a complete age.

    I've tried

    Please Login or Register  to view this content.
    and also a loop but I am not having much success with speeding it up.

    Is there an alternative way of getting the above macro to run faster?

    Help
    Last edited by Ratso; 04-25-2019 at 08:57 AM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,970

    Re: Speed up vba formula efficiently

    Why are you using FormulaArray? This does not appear to be an array formula, and that could be part of the reason for the long time. You might try Formula instead.

    Why are you doing this in VBA instead of putting the formula directly in the worksheet?

    If my suggestion does not help I suggest you attach your file with sample data, although it appears that it has private data that you would have to blank out.

    By the way, using 'BANK HOLIDAYS'!C1 probably will not do what you want. That argument has to be a range that has a list of dates for holidays, and you have provided just a single cell.
    Last edited by 6StringJazzer; 04-25-2019 at 11:25 AM. Reason: Grayed out incorrect comment, see later post for correction
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor
    Join Date
    06-30-2014
    Location
    London, England
    MS-Off Ver
    365 & 2010
    Posts
    107

    Re: Speed up vba formula efficiently

    Hi 6StringJazzer,

    Many thanks for the reply.

    Ok I have changed the Array to Formula. Still no luck.

    I have attached a sample worksheet with the DaysOverdue Macro which is currently running over 4 minutes.

    This is a heavy VBA workbook which requires the end user to push a button and the VBA does the rest and spits out the results in a separate worksheet for them to work. So manually adding the formula to the worksheet isn't an option.
    Attached Files Attached Files

  4. #4
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,411

    Re: Speed up vba formula efficiently

    As this would appear to be business related why use 'Working Days'.
    Surely settlement of debt is purely date related.
    i.e. settlement due in 30 days or 60 days etc., not dependent on 'holiday' variables.
    Make life easier for yourself and your cash-flow.
    torachan.

  5. #5
    Forum Contributor
    Join Date
    06-30-2014
    Location
    London, England
    MS-Off Ver
    365 & 2010
    Posts
    107

    Re: Speed up vba formula efficiently

    Hi Torachan,


    This is a unbilled report that is sent to different sites because of issues. The days overdue column tells the site the working days age of the account when it exceeds over so many working days then the account is written off and they get told off

    Odd I know but in my business and these types of accounts we work in actual working days hence the BANK HOLIDAYS tab.

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,970

    Re: Speed up vba formula efficiently

    Quote Originally Posted by 6StringJazzer View Post
    By the way, using 'BANK HOLIDAYS'!C1 probably will not do what you want. That argument has to be a range that has a list of dates for holidays, and you have provided just a single cell.
    I forgot that you were using R1C1 notation here so this comment is incorrect. However, you are using the entire column. That is part of the problem.

    I created a named range for your holiday list, and updated the code. This now runs in a couple of seconds.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    06-30-2014
    Location
    London, England
    MS-Off Ver
    365 & 2010
    Posts
    107

    Re: Speed up vba formula efficiently

    Hi 6StringJazzer,

    Works perfectly. Many thanks

  8. #8
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,970

    Re: Speed up vba formula efficiently

    You are very welcome, and thanks for the rep!

+ 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. How to avoid cell SELECTION but still format cells to speed up the macro running speed
    By BeefyBerts in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-05-2018, 08:18 AM
  2. Everage Speed km/time (european speed)
    By GerryZucca in forum Excel General
    Replies: 3
    Last Post: 02-23-2015, 03:02 PM
  3. formula for speed
    By robert.begley1 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-17-2014, 08:37 AM
  4. How to efficiently append to a formula that you can't fill-down
    By seanspotatobusiness in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-26-2014, 10:48 AM
  5. [SOLVED] How to efficiently change function, leaving the rest of the formula intact?
    By seanspotatobusiness in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-24-2014, 10:40 AM
  6. speed up formula
    By khalid79m in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-28-2007, 02:00 PM
  7. Speed up formula?
    By natepen in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-07-2007, 03:46 PM

Tags for this Thread

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