Error of "application-defined or object-defined error" in Goalseek

E

Edward Wang

Hi all,
I always have above error while running below code in the excel 2007,
please help me out!

Sub GoalSeekTry()
Source = Cells(8, 7)
x = Cells(7, 7).Value
ActiveSheet.Range(Source).GoalSeek Goal:=-800,
ChangingCell:=ActiveSheet.Range(x)
End With
End Sub

Source = X*X +X*300

Regards,
Edward
 
E

Edward Wang

sorry adjust the code little bit by removing "End With"

Sub GoalSeekTry()
Source = Cells(8, 7)
x = Cells(7, 7).Value
ActiveSheet.Range(Source).GoalSeek Goal:=-800,
ChangingCell:=ActiveSheet.Range(x)
End Sub
 
A

aflatoon

Your code is unclear to me, but I think you mean:


Code:
--------------------



Sub GoalSeekTry()
Set Source = Cells(8, 7)
Source.GoalSeek Goal:=-800, ChangingCell:=ActiveSheet.Cells(7, 7)
End Sub
--------------------




sorry adjust the code little bit by removing "End With"
Sub GoalSeekTry()
Source = Cells(8, 7)
x = Cells(7, 7).Value
ActiveSheet.Range(Source).GoalSeek Goal:=-800,
ChangingCell:=ActiveSheet.Range(x)
End Sub
 
E

Edward Wang

Yes, that is correct!

aflatoon said:
Your code is unclear to me, but I think you mean:




Sub GoalSeekTry()
Set Source = Cells(8, 7)
Source.GoalSeek Goal:=-800, ChangingCell:=ActiveSheet.Cells(7, 7)
End Sub sorry adjust the code little bit by removing "End With"


--
aflatoon

Regards,
A.
------------------------------------------------------------------------
aflatoon's Profile: http://www.thecodecage.com/forumz/member.php?u=1501
View this thread: http://www.thecodecage.com/forumz/showthread.php?t=202520

http://www.thecodecage.com/forumz

.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top