+ Reply to Thread
Results 1 to 2 of 2

Area Sub Function not calculating correctly

  1. #1
    Registered User
    Join Date
    09-13-2012
    Location
    Maine
    MS-Off Ver
    Excel 2010
    Posts
    45

    Area Sub Function not calculating correctly

    Could someone take a look at my Public Sub Area ()? It looks like it is calculating the area between the two graphs incorrectly and it is very important this piece is accurate. I need to calculate the difference between the areas of the two graph lines and list that difference in cell (A,94). A is the row in reference. The Sub is found in Sheet 6 of the attached excel sheet (sheet example with data) and below:
    Please Login or Register  to view this content.
    ExcelArea.xlsb

    Thank you very much in advance.

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

    Re: Area Sub Function not calculating correctly

    Debugging can be as important as coding. Is there a specific part of debugging this that you need help with? I cannot see anything wrong in a quick perusal. Why do you think it is giving you an incorrect answer? What answer do you expect.

    Here's how I would go about debugging this:

    1) Set up a scenario where I know what the answer should be -- and where I know all of the intermediate values along the way. If you know the solution and intermediate values to either one of the scenarios in your sample, that should be good enough.
    2) Add Stop statements at key points in the procedure. One should probably be right after the block If that is calculating Area1 and Area2
    3) Run the code. When it stops, check the values for each variable and see if the value currently stored matches the value I know it to be. If everything matches, then continue to the next stop statement (or step through one line at a time).
    4) Continue this until you can identify the calculation steps that are different from what you know them to be. Then you can focus on those quantities and calculation steps to figure out what you need to do differently.

    I know that this can get tedious and frustrating. We'll be happy to help where we can.

    If it helps, I set up one test case that I think should help (assuming I understand what you are trying to do here). This case should exactly match the red and green curves in your graph, so that the area between the test row and your curves should be 0. It obviously isn't, but it might be a good test case to see what is going on.
    Attached Files Attached Files
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

+ 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. vba to set print area not working correctly
    By bqheng in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-14-2015, 12:06 AM
  2. DAYS function: correctly calculating the number of days
    By dadpad in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-25-2015, 09:18 PM
  3. Formula not calculating correctly
    By mgfuentes in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 11-09-2012, 01:21 PM
  4. Count function not calculating correctly
    By jetty52 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-27-2011, 08:00 AM
  5. UDF Function to calculate Sheet Offset not calculating correctly
    By maurocam in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-04-2011, 07:57 AM
  6. Formula Not Calculating Correctly
    By be965 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-23-2007, 03:30 PM
  7. Date Not calculating correctly
    By vbehler in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-18-2007, 05:01 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