+ Reply to Thread
Results 1 to 5 of 5

Explanatory Formulas

  1. #1
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Explanatory Formulas

    Requirements:

    - Basic knowledge of vba
    - Use of tables/named ranges

    When working with workbooks on and off, sometimes months between revisits to the workbook it can be hard to remember the data structure and formula set up.
    This is how I work around this problem and ensure that I within a few minutes will have an overview of the calculations done.
    In this example I will show how a formula for calculating bonuses can be simplified.

    Formula appearance without table or UDF

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    The logic in this formula can be hard to extract at first glance.

    Formula appearance with table and no UDF

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    With tables it just got a bit easier to read as you are informed of the cells used in the calculation

    Formula appearance with table and UDF

    User defined function inserted in a module:
    Please Login or Register  to view this content.
    Use of the function

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    This tells you exactly what is happening at a first glance, and you can allways go deeper into the code to read the specifics.

    Attached is a file demonstrating all three scenarios
    Attached Files Attached Files
    Please take time to read the forum rules

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Explanatory Formulas

    And then when the bonus methodology changes, your function name makes no sense.
    IMO it would be better to have a function called simply GetBonus, and comment it to explain the calculation.
    Remember what the dormouse said
    Feed your head

  3. #3
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Explanatory Formulas

    @romperstomper

    Valid point though IMO if the function methodology changes, so should the function name, im a strong supporter of selfexplanatory function names.

    The post though was more directed at the concept of using UDF's and tables to give an overview than the specific function.

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Explanatory Formulas

    Quote Originally Posted by Steffen Thomsen View Post
    im a strong supporter of selfexplanatory function names.
    As am I, but not to that extent! I think the name should describe what it does, not how.

  5. #5
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Explanatory Formulas

    Actually im inclined to agree with you that the function name in this example is a bit over the edge, though it underlines the purpose of using this method.

+ 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