Goal Seek

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I wrote the following code to calculate IRR.

Sub IRR()
Dim X As String
X = Range("F9").Value
Range("H9").GoalSeek Goal:=X, ChangingCell:=Range("F4")
End Sub

This works fine alone, but when I put it in a Command Button and use:
Call IRR

I get the following error:

"GoalSeek Method of Range Class Failed"

Does anyone know what the problem is?

Thanks
 
Just a guess, but:
If your using Excel 97, change the takefocusonclick property of the command
button to false.
 
Thanks

That solution worked for me.

Tom Ogilvy said:
Just a guess, but:
If your using Excel 97, change the takefocusonclick property of the command
button to false.
 
Back
Top