Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Goalseek "may not have found a solution"

I am using the goalseek as follows

Range("H5").GoalSeek Goal:=0, ChangingCell:=Range("E5")

Sometimes I don't get a result. Manual running of the goal seek would give
me: May not have found a solution.
Whereas in VBA I don't get such a warning and the result is dumped in my
oupput cell. Is there some kind of flag or anything which could tell me if
the goal seek has found a solution or not...?


--
- Mangesh
------------------------------------------
Office 2003 & Windows XP


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Goalseek "may not have found a solution"

Check if the goal is met.

--
Regards,
Tom Ogilvy

"Mangesh Yadav" wrote in message
...
I am using the goalseek as follows

Range("H5").GoalSeek Goal:=0, ChangingCell:=Range("E5")

Sometimes I don't get a result. Manual running of the goal seek would give
me: May not have found a solution.
Whereas in VBA I don't get such a warning and the result is dumped in my
oupput cell. Is there some kind of flag or anything which could tell me if
the goal seek has found a solution or not...?


--
- Mangesh
------------------------------------------
Office 2003 & Windows XP




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Goalseek "may not have found a solution"

Hi Tom,

Thanks.
So thats the only way.

Mangesh




"Tom Ogilvy" wrote in message
...
Check if the goal is met.

--
Regards,
Tom Ogilvy

"Mangesh Yadav" wrote in message
...
I am using the goalseek as follows

Range("H5").GoalSeek Goal:=0, ChangingCell:=Range("E5")

Sometimes I don't get a result. Manual running of the goal seek would

give
me: May not have found a solution.
Whereas in VBA I don't get such a warning and the result is dumped in my
oupput cell. Is there some kind of flag or anything which could tell me

if
the goal seek has found a solution or not...?


--
- Mangesh
------------------------------------------
Office 2003 & Windows XP






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Goalseek "may not have found a solution"

It isn't the only way. You could consult the help on goalseek and see:

"Returns True if the goal seek is successful."

Dim bRes as Boolean
bRes = Range("H5").GoalSeek( Goal:=0, ChangingCell:=Range("E5"))

Trusting the help - I haven't tested it.


--
Regards,
Tom Ogilvy


"Mangesh Yadav" wrote in message
...
Hi Tom,

Thanks.
So thats the only way.

Mangesh




"Tom Ogilvy" wrote in message
...
Check if the goal is met.

--
Regards,
Tom Ogilvy

"Mangesh Yadav" wrote in message
...
I am using the goalseek as follows

Range("H5").GoalSeek Goal:=0, ChangingCell:=Range("E5")

Sometimes I don't get a result. Manual running of the goal seek would

give
me: May not have found a solution.
Whereas in VBA I don't get such a warning and the result is dumped in

my
oupput cell. Is there some kind of flag or anything which could tell

me
if
the goal seek has found a solution or not...?


--
- Mangesh
------------------------------------------
Office 2003 & Windows XP








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Goalseek "may not have found a solution"

Hi Tom,

Thank you very much. Will give it a try, and if it does not work, will come
back.

Mangesh



"Tom Ogilvy" wrote in message
...
It isn't the only way. You could consult the help on goalseek and see:

"Returns True if the goal seek is successful."

Dim bRes as Boolean
bRes = Range("H5").GoalSeek( Goal:=0, ChangingCell:=Range("E5"))

Trusting the help - I haven't tested it.


--
Regards,
Tom Ogilvy


"Mangesh Yadav" wrote in message
...
Hi Tom,

Thanks.
So thats the only way.

Mangesh




"Tom Ogilvy" wrote in message
...
Check if the goal is met.

--
Regards,
Tom Ogilvy

"Mangesh Yadav" wrote in message
...
I am using the goalseek as follows

Range("H5").GoalSeek Goal:=0, ChangingCell:=Range("E5")

Sometimes I don't get a result. Manual running of the goal seek

would
give
me: May not have found a solution.
Whereas in VBA I don't get such a warning and the result is dumped

in
my
oupput cell. Is there some kind of flag or anything which could tell

me
if
the goal seek has found a solution or not...?


--
- Mangesh
------------------------------------------
Office 2003 & Windows XP












  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Goalseek "may not have found a solution"

Hi Tom / Dana,

It works, and works well. Thanks to both of you.

Mangesh




"Tom Ogilvy" wrote in message
...
It isn't the only way. You could consult the help on goalseek and see:

"Returns True if the goal seek is successful."

Dim bRes as Boolean
bRes = Range("H5").GoalSeek( Goal:=0, ChangingCell:=Range("E5"))

Trusting the help - I haven't tested it.


--
Regards,
Tom Ogilvy


"Mangesh Yadav" wrote in message
...
Hi Tom,

Thanks.
So thats the only way.

Mangesh




"Tom Ogilvy" wrote in message
...
Check if the goal is met.

--
Regards,
Tom Ogilvy

"Mangesh Yadav" wrote in message
...
I am using the goalseek as follows

Range("H5").GoalSeek Goal:=0, ChangingCell:=Range("E5")

Sometimes I don't get a result. Manual running of the goal seek

would
give
me: May not have found a solution.
Whereas in VBA I don't get such a warning and the result is dumped

in
my
oupput cell. Is there some kind of flag or anything which could tell

me
if
the goal seek has found a solution or not...?


--
- Mangesh
------------------------------------------
Office 2003 & Windows XP










  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Goalseek "may not have found a solution"

Hi Tom,

Actually had checked the help before, but hadn't bothered to go through the
first part where it said: Returns True if the goal seek is successful. Just
checked the example and didn't find anything like a flag for success. Guess
the example always doesn't show everything. Anyway, thanks again.

Mangesh




"Tom Ogilvy" wrote in message
...
It isn't the only way. You could consult the help on goalseek and see:

"Returns True if the goal seek is successful."

Dim bRes as Boolean
bRes = Range("H5").GoalSeek( Goal:=0, ChangingCell:=Range("E5"))

Trusting the help - I haven't tested it.


--
Regards,
Tom Ogilvy


"Mangesh Yadav" wrote in message
...
Hi Tom,

Thanks.
So thats the only way.

Mangesh




"Tom Ogilvy" wrote in message
...
Check if the goal is met.

--
Regards,
Tom Ogilvy

"Mangesh Yadav" wrote in message
...
I am using the goalseek as follows

Range("H5").GoalSeek Goal:=0, ChangingCell:=Range("E5")

Sometimes I don't get a result. Manual running of the goal seek

would
give
me: May not have found a solution.
Whereas in VBA I don't get such a warning and the result is dumped

in
my
oupput cell. Is there some kind of flag or anything which could tell

me
if
the goal seek has found a solution or not...?


--
- Mangesh
------------------------------------------
Office 2003 & Windows XP










  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default Goalseek "may not have found a solution"

Here's another option:

Dim Ok As Boolean
Ok = Range("B1").GoalSeek(Goal:=0, ChangingCell:=Range("A1"))

I've never seen that message though. Maybe your function is highly
oscillatory. If so, perhaps as a general idea you can begin with a
different starting value.
You will want to limit the number of loops here though.

Do While Not Ok
[A1] = [A1] + 100 * Rnd - 50
Ok = Range("B1").GoalSeek(Goal:=0, ChangingCell:=Range("A1"))
Loop

Again, just a general idea to try.
Note that a True result (ie Found a solution) is returned if the answer is
close. Looks like "Close" is around 10^-4.

HTH
--
Dana DeLouis
Win XP & Office 2003


"Mangesh Yadav" wrote in message
...
Hi Tom,

Thanks.
So thats the only way.

Mangesh




"Tom Ogilvy" wrote in message
...
Check if the goal is met.

--
Regards,
Tom Ogilvy

"Mangesh Yadav" wrote in message
...
I am using the goalseek as follows

Range("H5").GoalSeek Goal:=0, ChangingCell:=Range("E5")

Sometimes I don't get a result. Manual running of the goal seek would

give
me: May not have found a solution.
Whereas in VBA I don't get such a warning and the result is dumped in
my
oupput cell. Is there some kind of flag or anything which could tell me

if
the goal seek has found a solution or not...?


--
- Mangesh
------------------------------------------
Office 2003 & Windows XP








  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default Goalseek "may not have found a solution"

Here's an example of a Polynomial that has no zero solution. The program
tries 100 times and gives up.

Sub Demo()
Dim Ok As Boolean
Dim Counter As Long

[A1].Clear
[B1].Formula = "=5*A1^2-2*A1+5"

Do While Not Ok And Counter < 100
[A1] = [A1] + 1000 * Rnd - 500
Ok = Range("B1").GoalSeek(Goal:=0, ChangingCell:=Range("A1"))
Counter = Counter + 1
Loop

If Counter = 100 Then
MsgBox ("No solution found in 100 attempts")
End If
End Sub


Another option may be to limit your starting values to a specific range.
Maybe something like:

For j = -10 To 10 Step 0.1
[A1] = j
ok = Range("B1").GoalSeek(Goal:=0, ChangingCell:=Range("A1"))
If ok Then Exit For
Next j

--
Dana DeLouis
Win XP & Office 2003


"Dana DeLouis" wrote in message
...
Here's another option:

Dim Ok As Boolean
Ok = Range("B1").GoalSeek(Goal:=0, ChangingCell:=Range("A1"))

I've never seen that message though. Maybe your function is highly
oscillatory. If so, perhaps as a general idea you can begin with a
different starting value.
You will want to limit the number of loops here though.

Do While Not Ok
[A1] = [A1] + 100 * Rnd - 50
Ok = Range("B1").GoalSeek(Goal:=0, ChangingCell:=Range("A1"))
Loop

Again, just a general idea to try.
Note that a True result (ie Found a solution) is returned if the answer
is close. Looks like "Close" is around 10^-4.

HTH
--
Dana DeLouis
Win XP & Office 2003


"Mangesh Yadav" wrote in message
...
Hi Tom,

Thanks.
So thats the only way.

Mangesh




"Tom Ogilvy" wrote in message
...
Check if the goal is met.

--
Regards,
Tom Ogilvy

"Mangesh Yadav" wrote in message
...
I am using the goalseek as follows

Range("H5").GoalSeek Goal:=0, ChangingCell:=Range("E5")

Sometimes I don't get a result. Manual running of the goal seek would

give
me: May not have found a solution.
Whereas in VBA I don't get such a warning and the result is dumped in
my
oupput cell. Is there some kind of flag or anything which could tell
me

if
the goal seek has found a solution or not...?


--
- Mangesh
------------------------------------------
Office 2003 & Windows XP










  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Goalseek "may not have found a solution"

Hi Dana

Thank you very much. Will give it a try, and if it does not work, will come
back.
Yes, my function does not always have a solution. It is based on the
different values that I supply to it. It is bound to fail for a few.

Mangesh



"Dana DeLouis" wrote in message
...
Here's another option:

Dim Ok As Boolean
Ok = Range("B1").GoalSeek(Goal:=0, ChangingCell:=Range("A1"))

I've never seen that message though. Maybe your function is highly
oscillatory. If so, perhaps as a general idea you can begin with a
different starting value.
You will want to limit the number of loops here though.

Do While Not Ok
[A1] = [A1] + 100 * Rnd - 50
Ok = Range("B1").GoalSeek(Goal:=0, ChangingCell:=Range("A1"))
Loop

Again, just a general idea to try.
Note that a True result (ie Found a solution) is returned if the answer

is
close. Looks like "Close" is around 10^-4.

HTH
--
Dana DeLouis
Win XP & Office 2003


"Mangesh Yadav" wrote in message
...
Hi Tom,

Thanks.
So thats the only way.

Mangesh




"Tom Ogilvy" wrote in message
...
Check if the goal is met.

--
Regards,
Tom Ogilvy

"Mangesh Yadav" wrote in message
...
I am using the goalseek as follows

Range("H5").GoalSeek Goal:=0, ChangingCell:=Range("E5")

Sometimes I don't get a result. Manual running of the goal seek would

give
me: May not have found a solution.
Whereas in VBA I don't get such a warning and the result is dumped in
my
oupput cell. Is there some kind of flag or anything which could tell

me
if
the goal seek has found a solution or not...?


--
- Mangesh
------------------------------------------
Office 2003 & Windows XP












Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Solution "Your changes could not be saved" "The document may be read-only or encrypted" [email protected] Excel Discussion (Misc queries) 0 August 7th 06 06:31 AM
"GoalSeek method of Range object failed" error message Fixit_Steve Excel Programming 0 January 13th 05 07:29 PM
Getting "compile error" "method or data member not found" on reinstall Bp Excel Programming 1 April 23rd 04 04:42 PM


All times are GMT +1. The time now is 11:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"