Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 846
Default Not existing procedure correctly

I was getting an error when the solver couldn't come up with the answer.
Added logic to handle the error. Now I get the msgbox showing up even when
solver comes up with the answer. What am I doing wrong.

Sub Solve_for_Face()
Dim cntr As Integer
shtSolve.Unprotect "Canada"
If shtSolve.Range("z19").Value < 5000 Then
shtSolve.Range("z19").Value = 5000
End If
shtSolve.Range("aa25").GoalSeek Goal:=shtSolve.Range("aa26"), _
ChangingCell:=shtSolve.Range("z19")

Do
On Error GoTo newprem
shtSolve.Range("z19").Value = Round(shtSolve.Range("z19").Value, 3)
+ 0.001
Loop Until shtSolve.Range("aa25").Value shtSolve.Range("aa26").Value
shtSolve.Range("z19").Value = shtSolve.Range("z19").Value - 0.001
shtSummary.Range("UnitAmt") = Int(shtSolve.Range("z19") * 1000)
shtSummary.Range("UnitADB") = Int(shtSolve.Range("z21") * 1000)
shtSummary.Protect "Canada"
Exit Sub
newprem:
MsgBox "cannot solve for face enter different premium"
shtSummary.Protect "Canada"
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 227
Default Not existing procedure correctly

I'll hazard a guess here. It looks to me as though your Do...Loop is
testing on two values (AA25 and AA26) that will never change during
the looping. If it loops once, it will loop forever. So your error
might be related to that rather than the "solver" (GoalSeek?) code.

On Jun 15, 2:58 pm, Brad wrote:
I was getting an error when the solver couldn't come up with the answer.
Added logic to handle the error. Now I get the msgbox showing up even when
solver comes up with the answer. What am I doing wrong.

Sub Solve_for_Face()
Dim cntr As Integer
shtSolve.Unprotect "Canada"
If shtSolve.Range("z19").Value < 5000 Then
shtSolve.Range("z19").Value = 5000
End If
shtSolve.Range("aa25").GoalSeek Goal:=shtSolve.Range("aa26"), _
ChangingCell:=shtSolve.Range("z19")

Do
On Error GoTo newprem
shtSolve.Range("z19").Value = Round(shtSolve.Range("z19").Value, 3)
+ 0.001
Loop Until shtSolve.Range("aa25").Value shtSolve.Range("aa26").Value
shtSolve.Range("z19").Value = shtSolve.Range("z19").Value - 0.001
shtSummary.Range("UnitAmt") = Int(shtSolve.Range("z19") * 1000)
shtSummary.Range("UnitADB") = Int(shtSolve.Range("z21") * 1000)
shtSummary.Protect "Canada"
Exit Sub
newprem:
MsgBox "cannot solve for face enter different premium"
shtSummary.Protect "Canada"
End Sub



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
Formatting worksheets, existing and new, in existing workbooks G. Dagger[_2_] Excel Discussion (Misc queries) 4 January 7th 08 06:48 PM
How to jump from a Form procedure to a Workbook or Module procedure? T. Erkson Excel Programming 4 January 25th 07 07:15 PM
download existing spreadsheets into another existing spreadsheet lbierer Excel Discussion (Misc queries) 2 September 24th 06 08:36 PM
How do I specify an existing procedure to run from a control adde. NeedExcelHelp Excel Programming 1 December 1st 04 01:37 PM


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