Spread Windows Forms 13.0 Product Documentation
Spread Windows Forms 13.0 Product Documentation / Developer's Guide / Customizing Interaction in Cells / Managing Formulas in Cells / Finding a Value Using GoalSeek
In This Topic
    Finding a Value Using GoalSeek
    In This Topic

    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)