Simple Goal Seek Procedure
Unfortunately Excel's goal seeking feature forces you to hand-enter a value into the "To value" field of the input box. You can't directly tie this input to a cell like you can with the "Set cell" and "By changing cell" inputs (see the screenshot below).
This can make things difficult especially if you're trying to seek very large values or values that that are carried out to many decimal points.
The following procedure allows you to get around this limitation. First, enter the cell addresses for the variables called Rng1, Rng2, and Rng3. Note that a formula must appear in Rng1 and a value must be entered into Rng3. Next, run the procedure.
Sub GoalSeek()
Dim Rng1 As Range
Dim Rng2 As Range
Dim Rng3 As Range
On Error GoTo errHandler:
'Set the value in this cell
Set Rng1 = ActiveSheet.Range("C4")
'Equal to the value in this cell
'Note: This cell must contain a formula
Set Rng2 = ActiveSheet.Range("C7")
'By changing the value in this cell
Set Rng3 = ActiveSheet.Range("C2")
If Rng1.HasFormula = True Then
If IsNumeric(Rng3) = True Then
Rng1.GoalSeek Goal:=Rng2, ChangingCell:=Rng3
End If
End If
Exit Sub
errHandler:
MsgBox "Procedure failed - please check inputs."
End Sub