# Goal Seek

This topic explains how to use the Goal Seek feature when working with formulas in the Spread for WPF.

## Content

Spread for WPF provides a Goal Seek feature that helps you to find the input values needed to achieve a specific result in your formulas. This is particularly useful when you're unsure about the data values required for a desired formula output. You can determine the input value needed to reach your target result by using the [GoalSeek](/spreadnet/api/latest/online-wpf/GrapeCity.Spreadsheet/GrapeCity.Spreadsheet.IRange.GoalSeek.html) method of the **IRange** interface.
The following image illustrates the maximum loan principal a person can afford based on the given interest rate, loan term, and monthly payment. The adjusted loan amount is $186,282, which is the maximum loan the person can afford with a $1,000 monthly payment.
![](https://cdn.mescius.io/document-site-files/images/0f63724f-fddf-4351-8c24-0b4338c0fda9/images/goal-seek.png)
Refer to the following example code to configure the GoalSeek method to determine the loan amount that results in a monthly payment of $1000.
**C#**

```csharp
spreadSheet1.Workbook.ActiveSheet.Cells["A2"].Text = "Interest Rate";
spreadSheet1.Workbook.ActiveSheet.Cells["B2"].Value = 0.05;
spreadSheet1.Workbook.ActiveSheet.Cells["A3"].Text = "Loan Term (Years)";
spreadSheet1.Workbook.ActiveSheet.Cells["B3"].Value = 30;
spreadSheet1.Workbook.ActiveSheet.Cells["A4"].Text = "Loan Amount";
spreadSheet1.Workbook.ActiveSheet.Cells["A5"].Text = "Monthly Payment";
spreadSheet1.Workbook.ActiveSheet.Cells["B5"].Formula = "PMT(B2/12, B3*12, -B4)";
spreadSheet1.Workbook.ActiveSheet.Cells["B5"].GoalSeek(1000, "B4", true);
```

**VB**

```auto
spreadSheet1.Workbook.ActiveSheet.Cells("A2").Text = "Interest Rate"
spreadSheet1.Workbook.ActiveSheet.Cells("B2").Value = 0.05
spreadSheet1.Workbook.ActiveSheet.Cells("A3").Text = "Loan Term (Years)"
spreadSheet1.Workbook.ActiveSheet.Cells("B3").Value = 30
spreadSheet1.Workbook.ActiveSheet.Cells("A4").Text = "Loan Amount"
spreadSheet1.Workbook.ActiveSheet.Cells("A5").Text = "Monthly Payment"
spreadSheet1.Workbook.ActiveSheet.Cells("B5").Formula = "PMT(B2/12, B3*12, -B4)"
spreadSheet1.Workbook.ActiveSheet.Cells("B5").GoalSeek(1000, "B4", True)
```