Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA code to perform summation and product summation
I am in the process of writing VBA code to perform Lagrang
interpolation and I am not sure how to write the code for the Lagrang polynomial function. This function is in the attachment labele "LIP.xls". The problem is that this function involves a summation an a product summation and I am not sure how to handle this in VBA code. My spreadsheet is attached as "exp.xls". In this spreadsheet, the use may input as many data points (x and y values) as they wish. Then the can input an x value and the macro should calculate the interpolated value. For the values currently in the spreadsheet (x = 3); y = 493.84 NOTE: Even though the spreadsheet currently contains only three dat points, the user may input as many data points as they wish. The excel spreadsheet attached gives an example of how the Lagrang polynomial should be calculated for the values currently in th spreadsheet. Here is the code I have written so far Private Sub Worksheet_Change(ByVal Target As Range) Dim xn, yn, x If Target.Address = "$D$5" Then xn = Application.WorksheetFunction.CountA(Columns("A:A" )) - 3 yn = Application.WorksheetFunction.CountA(Columns("B:B" )) - 1 If xn < yn Then MsgBox ("There must be the same number of x's as y's"), , "Hold Up!" Exit Sub End If x = Range("D5").Value ????????????What should go here????????????? End If End Sub How may I write a VBA macro to perform this task? Please Help! Thanks Attachment filename: lip.xls Download attachment: http://www.excelforum.com/attachment.php?postid=54635 -- Message posted from http://www.ExcelForum.com |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I perform summation over variable areas? | Excel Discussion (Misc queries) | |||
How can perform a summation? | Excel Worksheet Functions | |||
Summation | Excel Programming | |||
Summation | Excel Programming | |||
VBA : VBA code for summation formula | Excel Programming |