Hello Board,
So I have been working on a timer code that updates a sheet and repeats. It works just how I want it 60% of the time. Sometimes it works then skips an update then works again. Other times it continues to just skip the update.
If you have any Ideas please let me know.
Thanks a bunch
So I have been working on a timer code that updates a sheet and repeats. It works just how I want it 60% of the time. Sometimes it works then skips an update then works again. Other times it continues to just skip the update.
Code:
Private Sub CommandButton1_Click()Dim t, E, M As Double, S As Double
t = Timer
AllowedTime = Int(Sheet1.Range("b1").Value)
Do
Application.EnableEvents = True
If Timer - t < 0 Then
Unload UserForm1
MsgBox "Error encountered - start again"
Exit Sub
End If
E = CDbl(Time) * 24 * 60 * 60 - t
M = CDbl(AllowedTime) - 1 - Int(E / 60)
S = 59 - Round((E / 60 - Int(E / 60)) * 60, 0)
With tBx1
.Value = Format(CStr(M), "00") & ":" & Format(CStr(S), "00")
End With
DoEvents
If (Timer - t) / 60 = CDbl(AllowedTime) Then
Range("A28").Value = Range("A28").Value + 1
Range("B1").Value = "=VLOOKUP(A28,A2:E26,2,0)"
Range("B1") = Range("B1")
Range("C1").Value = "=VLOOKUP(A28,A2:E26,3,0)"
Range("C1") = Range("C1")
Range("D1").Value = "=VLOOKUP(A28,A2:E26,4,0)"
Range("D1") = Range("D1")
Range("E1").Value = "=VLOOKUP(A28,A2:E26,5,0)"
Range("E1") = Range("E1")
Range("B27").Value = "=VLOOKUP(A28+1,A2:E26,2,0)"
Range("B27") = Range("B27")
Range("C27").Value = "=VLOOKUP(A28+1,A2:E26,3,0)"
Range("C27") = Range("C27")
Range("D27").Value = "=VLOOKUP(A28+1,A2:E26,4,0)"
Range("D27") = Range("D27")
Range("E27").Value = "=VLOOKUP(A28+1,A2:E26,5,0)"
Range("E27") = Range("E27")
Range("G27").Value = "=(f27) & (G22*J22+G24*J24+G25*J25)"
Range("G28") = Range("G27")
Range("G26").Value = "=+G22*(K22+G24*K24+G25*K25)/G23"
Range("G26") = Range("G26")
End If
Loop Until (Timer - t) / 60 >= AllowedTime
Call CommandButton1_Click
End Sub
If you have any Ideas please let me know.
Thanks a bunch
Last edited by a moderator: