Spread ASP.NET 6.0 Product Documentation
Finding a Value with Goal Seeking
Send Feedback
Spread ASP.NET 6.0 Product Documentation > Developer's Guide > Managing Formulas > Finding a Value with Goal Seeking

Glossary Item Box

You can iteratively find the closest value for a cell that produces a desired formula result in another cell using the GoalSeek capability.

The GoalSeek method is in the FpSpread class.

For more information about formulas, refer to the Formula Reference.

Return to the overview of Managing Formulas.

Using Code

Use the GoalSeek method to get the required value.

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)
© 2002-2012 GrapeCity, Inc. All Rights Reserved.