+ Reply to Thread
Results 1 to 4 of 4

Convert to VBA Application.WorksheetFunction

  1. #1
    Forum Contributor
    Join Date
    06-08-2012
    Location
    Lagos, Nigeria
    MS-Off Ver
    Excel 2007, 2010, 2016
    Posts
    102

    Convert to VBA Application.WorksheetFunction

    Dear Reader,

    Can anybody help convert this formula to its VBA version.
    Please Login or Register  to view this content.
    Many thanks!
    Last edited by alansidman; 10-31-2015 at 12:20 PM.

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,949

    Re: Convert to VBA Application.WorksheetFunction

    I don't know that there will be a single "VBA version" of that formula. I'm also doubtful that it will fit in a single VBA statement. There will probably also be questions related to the procedure context (what variables are holding the information needed by this block of VBA code, what information does this block of VBA code need to find).

    Is there a specific part of converting this VBA that you have trouble with? For example, the "outer" IFERROR() function performs simple error trapping. Are you familiar with error trapping strategies in VBA? If not, you may want to review tutorials such as this (http://www.cpearson.com/Excel/ErrorHandling.htm ) to research how to handle errors in code.

    I also see some IF() functions in there. Can w assume that you are familiar with VBA If ... Then ... Else ... End If structures? https://msdn.microsoft.com/en-us/library/752y8abs.aspx If not, that would likely be more useful research. Your function looks like it is trying to choose between two different conditional sums, and this If ... then ... else ... end if seems like the closest equivalent in VBA:
    Please Login or Register  to view this content.
    Beyond that, as we break that ugly megaformula down into individual parts, are there specific parts that you do not understand how to convert to VBA?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Forum Contributor
    Join Date
    06-08-2012
    Location
    Lagos, Nigeria
    MS-Off Ver
    Excel 2007, 2010, 2016
    Posts
    102

    Re: Convert to VBA Application.WorksheetFunction

    Thanks MrShorty.. I was thinking it could be easier to convert to the VB version.

    The formula currently takes time to calculate in my current spreadsheet and so i though i can use the worksheetfunction and read the results back to my spreadsheet in a bit to cut down on the wait time.

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,949

    Re: Convert to VBA Application.WorksheetFunction

    What exactly is this function supposed to do? What are these two conditional sums? What does the source data look like? How many copies of this function are in the spreadsheet.

    Simple things that can speed up something like this:

    1) Your formula uses full row and column references. Unless you really are using the entire 1000000 row x 60000 column spreadsheet, many formulas are faster if you limit the references to a suitable size.

    2) It appears that your formula is using two named ranges. I recently learned that, depending on the exact structure, named ranges can slow calculation down: http://www.excelforum.com/excel-form...ml#post4218709 It would probably help to understand what those named ranges/formulas are and see if they are contributing to the slow calculation.

    3) https://msdn.microsoft.com/en-us/lib...ice.12%29.aspx This article has more than you probably want to read about spreadsheet performance. There are several suggestions given. The most common one I suggest is to unwrap these large, complex megaformulas into helper cells. Oftentimes, megaformulas like this are repeating the exact same calculation multiple times. By pulling the repeated calculation out into a helper cell, that calculation need only be performed once rather than hundreds of times.

    4) A lot of times, conditional sums like this turn out to be about "creating a summary report from a large database". Many times, these database reports can be accomplished much faster by using pivot tables. I personally am not very skilled at using pivot tables, but have seen many cases where a pivot table report calculates much faster than several SUMIFS().

    Those are a few ideas, I'm sure there are other suggestions that could be made. In order to really make specific suggestions, we would probably need you to upload a sample spreadsheet.

+ 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. [SOLVED] Application.WorksheetFunction vs Application.NormDist
    By Boo123 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-13-2014, 06:33 PM
  2. Application, WorksheetFunction or both?
    By Benni in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-04-2012, 08:59 PM
  3. Application.WorksheetFunction
    By roger09 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-29-2011, 09:07 AM
  4. Application.WorksheetFunction.CountIF
    By krsna83_pp in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-17-2011, 08:27 AM
  5. Application.WorksheetFunction.WorkDay
    By yuryyuryyury in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-12-2007, 03:51 PM
  6. application.worksheetfunction
    By Ozgur Pars in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-18-2006, 03:15 AM
  7. Application.WorksheetFunction problem
    By Gary''s Student in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 10-18-2005, 03:05 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