Possibly this would work for what you want to achieve
In the THISWORKBOOK object copy this code
- Code: Select all
Private Sub Workbook_Open()
Application.OnTime TimeValue("08:05:00"), "calculate_stake"
End Sub
This sets a time to run a macro named 'calculate_stake' at 08:05:00
Then put something like this in a MACRO
- Code: Select all
Private Sub calculate_stake()
Application.EnableEvents = False
Application.OnTime TimeValue("08:05:00"), "calculate_stake"
With ThisWorkbook.Sheets("Selections")
If .Range("m2").Value > .Range("n2").Value Then
.Range("n2").Value = .Range("m2").Value
ElseIf .Range("m2").Value <= (.Range("n2").Value) * (1 - Range("q2").Value) Then
.Range("n2").Value = .Range("m2").Value
End If
End With
Application.EnableEvents = True
End Sub
This sets the timer again when run and the code is set up for the following...
1. your stake info is on a worksheet named "Selections"
2. cell m2 is Current Bank
3. cell n2 is Max Bank
4. cel q2 is Stop at Loss x%
and performs the calc - if current bank is greater than max bank then max bank = current bank
or
if current bank is less than or equal to the stop loss amount adjust the max bank down to current bank