Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Nothing happens with range("B2").Goalseek _...

Could someone please tell me what I'm missing with using the goalseek
method?

A test spreadsheet taken from MSDN: GoalSeek Method [Excel 2003 VBA
Language Reference] illustrates the problem. Calling the VBA
seekgoal() function does not do anything. Here's the code, with notes:

' sheet 1 has cell b2 set to 6, named to "Polynomial"
' sheet 1 has cell b1 set to empty, named as "X"
' I call function seekgoal() from sheet1

Public Function seekgoal() As Boolean

P = Worksheets("Sheet1").Range("Polynomial") ' p is 6
Xt = Worksheets("Sheet1").Range("X") ' x is empty

Stop ' yep, were executing. range references are correct. [F8]
continues

Worksheets("Sheet1").Range("Polynomial").GoalSeek _
goal:=15, _
ChangingCell:=Worksheets("Sheet1").Range("X")
End Function

' but nothing happens: neither cell b1 nor b2 changed in sheet1. No
error messages occur.

Running Tools-Goal Seek from the spreadsheet finds a solution
(X = 1.426018623 and Polynomial = 15.00043772)

Thank you in advance. I appreciate any thoughts you have.

Phil

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Nothing happens with range("B2").Goalseek _...

Change from a Function to a Sub and it should work as desired.

Public seekgoal()
.......
End Sub

Hth,
Merjet


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
use variable in Workbooks("book1").Worksheets("sheet1").Range("a1" Luc[_3_] Excel Programming 2 September 28th 05 08:37 PM
Goalseek "may not have found a solution" Mangesh Yadav[_4_] Excel Programming 9 August 25th 05 05:34 AM
"GoalSeek method of Range object failed" error message Fixit_Steve Excel Programming 0 January 13th 05 07:29 PM
Using "Cells" to write "Range("A:A,H:H").Select" Trip Ives[_2_] Excel Programming 3 June 5th 04 03:13 PM


All times are GMT +1. The time now is 09:55 AM.

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

About Us

"It's about Microsoft Excel"