Saqib Husain
asked on
VBA code to find the area between two curves plotted in excel by exact method
I have two curves as shown in the attached file. The first one is a two-point straight line. The second is a series of straight lines. The missing values in the second one to be interpolated.
I need the total area between the two lines, the areas above and below to be returned separately. The area is also bounded by vertical lines through the end points of the first line.
I had asked this question earlier and the expert provided an approximate numerical method which takes a long time if the precision is increased.
https://www.experts-exchange.com/questions/28628119/VBA-code-to-find-the-area-between-two-curves-plotted-in-excel.html?anchorAnswerId=40643181#a40643181
I have provided a file showing the calculation steps which I am looking for. Can someone provide VBA code for the same?
Area-between-two-curves.xlsx
I need the total area between the two lines, the areas above and below to be returned separately. The area is also bounded by vertical lines through the end points of the first line.
I had asked this question earlier and the expert provided an approximate numerical method which takes a long time if the precision is increased.
https://www.experts-exchange.com/questions/28628119/VBA-code-to-find-the-area-between-two-curves-plotted-in-excel.html?anchorAnswerId=40643181#a40643181
I have provided a file showing the calculation steps which I am looking for. Can someone provide VBA code for the same?
Area-between-two-curves.xlsx
Oops !! just noticed you had 2 worksheets in this WB was looking at the first one. Just opened Calculation requirements and see all the explanations.
Will study all this to see if I can understand something !!! :)
will revert.
gowlfow
Will study all this to see if I can understand something !!! :)
will revert.
gowlfow
Try this exact calculation.
When all points exist, the areas are rectangles and triangles.
Area-between-two-curves-B.xlsm
When all points exist, the areas are rectangles and triangles.
Area-between-two-curves-B.xlsm
ASKER
Hi, thanks for the effort. But as my given file says,
I do not want to modify the source data.
Inputs are all yellow. White cells are formulas and need to be calculated in VBA - not displayed in the spreadsheet.
I do not want to modify the source data.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Looks goood but is failing for line data
X Y
1000 225
1344 226
X Y
1000 225
1344 226
Boundary checks added
Area-between-two-curves-C.xlsm
Area-between-two-curves-C.xlsm
ASKER
Hi, did not get chance to check the last post as I had done my own modification and got it to work. I also had to modify it (not part of the question) to stop at the ends of the curve 2 if curve 1 extended beyond.
Anyways, thanks for the effort. The basic thing is working just as I wished.
Anyways, thanks for the effort. The basic thing is working just as I wished.
Basically you want the Green part ? and if yes how do you want that ? not clear.
gowflow