simoncpage
Programmer
Hi All, I am using the following loop to work out a goal seek scenario where by it is factored by two different values:
Its quite long and hence a bit ugly but has anyone got any ideas how to make this speed things up?
--------------------------------------------------------
If (Range("Perc".Value - Range("base".Value) < Range("percseek".Value Then
Do
Range("marginsn".Value = Range("marginsn".Value - 0.0005
Range("year".Value = Term
Amortise
SubAmortise
If Range("Perc".Value - Range("base".Value > Range("percseek".Value Then
Exit Do
Else
End If
Loop
Do
Range("marginsn".Value = Range("marginsn".Value + 0.0001
Range("year".Value = Term
Amortise
SubAmortise
If Range("Perc".Value - Range("base".Value < Range("percseek".Value Then
Exit Do
Else
End If
Loop
Do
Range("marginsn".Value = Range("marginsn".Value - 0.00005
Range("year".Value = Term
Amortise
SubAmortise
If Range("Perc".Value - Range("base".Value > Range("percseek".Value Then
Exit Do
Else
End If
Loop
Do
Range("marginsn".Value = Range("marginsn".Value + 0.00001
Range("year".Value = Term
Amortise
SubAmortise
If Range("Perc".Value - Range("base".Value < Range("percseek".Value Then
Exit Do
Else
End If
Loop
Do
Range("marginsn".Value = Range("marginsn".Value - 0.000005
Range("year".Value = Term
Amortise
SubAmortise
If Range("Perc".Value - Range("base".Value > Range("percseek".Value Then
Exit Do
Else
End If
Loop
Range("marginsn".Value = Range("marginsn".Value + 0.000005
Range("year2".Value = Term
Else
Do
Range("marginsn".Value = Range("marginsn".Value + 0.0005
Range("year".Value = Term
Amortise
SubAmortise
If Range("Perc".Value - Range("base".Value < Range("percseek".Value Then
Exit Do
Else
End If
Loop
Do
Range("marginsn".Value = Range("marginsn".Value - 0.0001
Range("year".Value = Term
Amortise
SubAmortise
If Range("Perc".Value - Range("base".Value > Range("percseek".Value Then
Exit Do
Else
End If
Loop
Do
Range("marginsn".Value = Range("marginsn".Value + 0.00005
Range("year".Value = Term
Amortise
SubAmortise
If Range("Perc".Value - Range("base".Value < Range("percseek".Value Then
Exit Do
Else
End If
Loop
Do
Range("marginsn".Value = Range("marginsn".Value - 0.00001
Range("year".Value = Term
Amortise
SubAmortise
If Range("Perc".Value - Range("base".Value > Range("percseek".Value Then
Exit Do
Else
End If
Loop
Do
Range("marginsn".Value = Range("marginsn".Value + 0.000005
Range("year".Value = Term
Amortise
SubAmortise
If Range("Perc".Value - Range("base".Value < Range("percseek".Value Then
Exit Do
Else
End If
Loop
Range("marginsn".Value = Range("marginsn".Value - 0.000005
Range("year2".Value = Term
End If
End Sub
----------------------------------------
Any help would be great thanks!
Its quite long and hence a bit ugly but has anyone got any ideas how to make this speed things up?
--------------------------------------------------------
If (Range("Perc".Value - Range("base".Value) < Range("percseek".Value Then
Do
Range("marginsn".Value = Range("marginsn".Value - 0.0005
Range("year".Value = Term
Amortise
SubAmortise
If Range("Perc".Value - Range("base".Value > Range("percseek".Value Then
Exit Do
Else
End If
Loop
Do
Range("marginsn".Value = Range("marginsn".Value + 0.0001
Range("year".Value = Term
Amortise
SubAmortise
If Range("Perc".Value - Range("base".Value < Range("percseek".Value Then
Exit Do
Else
End If
Loop
Do
Range("marginsn".Value = Range("marginsn".Value - 0.00005
Range("year".Value = Term
Amortise
SubAmortise
If Range("Perc".Value - Range("base".Value > Range("percseek".Value Then
Exit Do
Else
End If
Loop
Do
Range("marginsn".Value = Range("marginsn".Value + 0.00001
Range("year".Value = Term
Amortise
SubAmortise
If Range("Perc".Value - Range("base".Value < Range("percseek".Value Then
Exit Do
Else
End If
Loop
Do
Range("marginsn".Value = Range("marginsn".Value - 0.000005
Range("year".Value = Term
Amortise
SubAmortise
If Range("Perc".Value - Range("base".Value > Range("percseek".Value Then
Exit Do
Else
End If
Loop
Range("marginsn".Value = Range("marginsn".Value + 0.000005
Range("year2".Value = Term
Else
Do
Range("marginsn".Value = Range("marginsn".Value + 0.0005
Range("year".Value = Term
Amortise
SubAmortise
If Range("Perc".Value - Range("base".Value < Range("percseek".Value Then
Exit Do
Else
End If
Loop
Do
Range("marginsn".Value = Range("marginsn".Value - 0.0001
Range("year".Value = Term
Amortise
SubAmortise
If Range("Perc".Value - Range("base".Value > Range("percseek".Value Then
Exit Do
Else
End If
Loop
Do
Range("marginsn".Value = Range("marginsn".Value + 0.00005
Range("year".Value = Term
Amortise
SubAmortise
If Range("Perc".Value - Range("base".Value < Range("percseek".Value Then
Exit Do
Else
End If
Loop
Do
Range("marginsn".Value = Range("marginsn".Value - 0.00001
Range("year".Value = Term
Amortise
SubAmortise
If Range("Perc".Value - Range("base".Value > Range("percseek".Value Then
Exit Do
Else
End If
Loop
Do
Range("marginsn".Value = Range("marginsn".Value + 0.000005
Range("year".Value = Term
Amortise
SubAmortise
If Range("Perc".Value - Range("base".Value < Range("percseek".Value Then
Exit Do
Else
End If
Loop
Range("marginsn".Value = Range("marginsn".Value - 0.000005
Range("year2".Value = Term
End If
End Sub
----------------------------------------
Any help would be great thanks!