Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
use variable in Workbooks("book1").Worksheets("sheet1").Range("a1" | Excel Programming | |||
Goalseek "may not have found a solution" | Excel Programming | |||
"GoalSeek method of Range object failed" error message | Excel Programming | |||
Using "Cells" to write "Range("A:A,H:H").Select" | Excel Programming |