You can use the GoalSeek method to find a value that will produce the desired result for a formula. An approximation is acceptable. You can set the starting and intended goal of the calculation.
Using Code
Use the GoalSeek method to find the required result.
Example
In this example the formula is in cell (1,1). The result that you want to see in the formula cell is 32. The value in C1 is what is required to get a result of 32.
C# | Copy Code |
---|---|
FpSpread1.Sheets[0].Cells[1, 1].Formula = "C1+D1";
FpSpread1.Sheets[0].Cells[0, 3].Value = 2;
FpSpread1.GoalSeek(0, 0, 2, 0, 1, 1, 32);
|
VB | Copy Code |
---|---|
FpSpread1.Sheets(0).Cells(1, 1).Formula = "C1+D1"
FpSpread1.Sheets(0).Cells(0, 3).Value = 2
FpSpread1.GoalSeek(0, 0, 2, 0, 1, 1, 32)
|