VBA Goal Seek To without going below zero

Viewed 19

I built a goal seek formula which works, however when you increase the target cell (G3) by too much of an increase, excel keeps reiterating into the negative and cant figure out a solution. Is there a way to add a condition to make the changing cell ("b2") have to be greater than negative, or make it so goal seek guesses is high enough that it will find the ideal positive goal seek before going negative. Here is the current code.

Private Sub Worksheet_Change(ByVal Target As Range)
     If Not Application.Intersect(Target, Range("g3")) Is Nothing Then
         Range("g21").GoalSeek Goal:=1.3, ChangingCell:=Range("b2")
     End If 
End Sub 
1 Answers

Figured it out. I set the changing range to be set to well above any potential answer, and then it will work every time.

> Private Sub Worksheet_Change(ByVal Target As Range)
>     If Not Application.Intersect(Target, Range("g3")) Is Nothing Then
>        Range("b2") = 1000000000
>         Range("g21").GoalSeek Goal:=1.3, ChangingCell:=Range("b2")
>     End If End Sub
Related