LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Call GoalSeek from a user-defined-function

User defined functions called from a worksheet can only return a value to
the cell in which they are entered. So it would be no surprise that
goalseek would not work from a UDF.

--
Regards,
Tom Ogilvy

"Mark" wrote in message
...
Hello,
I am trying to call GoalSeek within a function, but GoalSeek appears to
only work if called from a sub. For example, calling the function below

from
a cell will not update any cells, but having a button call the function

will.
Is there some contraint that GoalSeek must be triggered by a sub instead

of
being called from a user-defined function?

Function TestGoalSeek(rTarget As Range, rChange As Range, dblGoal As

Double)
As Double
Call DoGoalSeek(rTarget, rChange, dblGoal)
TestGoalSeek = rChange(1, 1)
End Function

Private Sub DoGoalSeek(rTarget As Range, rChange As Range, dblGoal As

Double)
'Range("F11").GoalSeek Goal:=10, ChangingCell:=Range("E11")
Dim b As Boolean
b = rTarget.GoalSeek(dblGoal, rChange)
End Sub

Thanks,
Mark



 
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
User Defined FUNCTION EAK Excel Discussion (Misc queries) 5 July 17th 08 07:07 PM
user defined function Brian Rogge Excel Worksheet Functions 5 May 23rd 05 06:21 PM
User defined function PC[_3_] Excel Programming 1 August 17th 04 04:58 PM
User-defined data type; Error: Only User-defined types... tiger_PRM Excel Programming 1 July 18th 04 03:32 PM
User-Defined Function pre-empting Built-in Function? How to undo???? MarWun Excel Programming 1 August 6th 03 09:31 PM


All times are GMT +1. The time now is 11:12 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"