Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi, thanks for helping
When I step through the following code (lots of junk removed so it should be easier to read) it works fine, however when I run it it works fine until i = 527 then I get an error, and TimetoPM's value is wrong. It comes out negative even when the formula makes it positive? For i = 1 To LoopNumber Step 1 Ttotal = 0 Tevent = 0 WeightedAge = 0 y = 1 x = 0 Do If WeightedAge = 0 Then Tf = Alpha * ((WeightedAge / Alpha) ^ Beta - Log(1 - Rnd)) ^ (1 / Beta) - WeightedAge TimeToPM = (Period * y - Ttotal) If Tf < TimeToPM Then 'If (Time to fail) < (Time of next SM - Time of Last Event) 'stuff in here but no defining of TimetoPM Else 'more stuff but TimetoPM is not changed WeightedAge = WeightedAge + TimeToPM * (1 - RestoreFactor) End If y = y + 1 'update SM multiple counter for System Time option End If Ttotal = Tevent + Tm Else x = 1 End If Loop While x = 0 Next |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It looks to me that if yoour Ttotal is greater than y or if RestoreFactor is
greater than 1 then TimetoPM will be negative. If that is the case, then you can put an error handling "If ... then" in there to accomodate it or use "on error next" to bypass it, depending on what you expect as a result. "sportzrule" wrote: Hi, thanks for helping When I step through the following code (lots of junk removed so it should be easier to read) it works fine, however when I run it it works fine until i = 527 then I get an error, and TimetoPM's value is wrong. It comes out negative even when the formula makes it positive? For i = 1 To LoopNumber Step 1 Ttotal = 0 Tevent = 0 WeightedAge = 0 y = 1 x = 0 Do If WeightedAge = 0 Then Tf = Alpha * ((WeightedAge / Alpha) ^ Beta - Log(1 - Rnd)) ^ (1 / Beta) - WeightedAge TimeToPM = (Period * y - Ttotal) If Tf < TimeToPM Then 'If (Time to fail) < (Time of next SM - Time of Last Event) 'stuff in here but no defining of TimetoPM Else 'more stuff but TimetoPM is not changed WeightedAge = WeightedAge + TimeToPM * (1 - RestoreFactor) End If y = y + 1 'update SM multiple counter for System Time option End If Ttotal = Tevent + Tm Else x = 1 End If Loop While x = 0 Next |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Creating a Drop Down List with Step by Step Instructions for 2007 | Excel Worksheet Functions | |||
How show value of variable by mouse-over in debug single step mode | Excel Programming | |||
How show value of variable in single step debug mode? | Excel Programming | |||
What is the step-by-step procedure for making a data list? | Excel Discussion (Misc queries) | |||
I need step by step instructions to create a macro for 10 imbedde. | Excel Worksheet Functions |