Thread: Vba goal seek
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Vba goal seek

Private Sub Worksheet_Calculate()
Application.EnableEvents = False
Range("A2").Formula = "=A1^2/10"
Range("B2").Formula = "=B1^3+C1"
Range("A2").Name = "AperC"
Range("B2").Name = "BperD"
Range("C2").Formula = "=AperC-BperD"
On Error GoTo TheEnd

Range("C2").GoalSeek Goal:=0, _
ChangingCell:=Range("C1")


TheEnd:
Application.EnableEvents = True
End Sub

Goalseek works on Cells.

--
Regards,
Tom Ogilvy


"csw78" wrote in
message ...

Hi. My intent is to find the value in Range("C1") when "AperC"="BperD".
"BperD" turns out to be an invalid qualifier for goal seek. I was
wondering if anyone know of a work around. Thank you much.
---------------------------------------------------------------
Private Sub Worksheet_Calculate()
Dim AperC as Double
Dim BperD as Double

AperC = Range("A1")^2 / 10
BperD = Range("B1")^3+Range("C1")

On Error GoTo TheEnd
Application.EnableEvents = False

Do Until AperC=BperD
BperD.GoalSeek Goal:=AperC, _
ChangingCell:=Range("C1")
Loop

TheEnd:
Application.EnableEvents = True
End Sub


--
csw78
------------------------------------------------------------------------
csw78's Profile:

http://www.excelforum.com/member.php...o&userid=23008
View this thread: http://www.excelforum.com/showthread...hreadid=376747