PDA

View Full Version : Solved: Problems with Private Sub



thomas.szwed
09-10-2008, 03:07 AM
Hi there,

I have the following sub in a module in one of my workbooks. It updates a cell to keep the time correct.

Sub UppdateraKlockan()
With Sheets("INPUT").Range("P35")
.Value = Now
.NumberFormat = "hh:mm"
End With
K?rN?r = Now + TimeSerial(0, 1, 0)
Application.OnTime earliesttime:=K?rN?r, _
procedure:="UppdateraKlockan", schedule:=True
End Sub

However if i open any new or saved workbook with the other workbook still open then I always get a 'Subscript Out of Range' Runtime error on tihs sub???? Can anyone help??

Thanks alot

Bob Phillips
09-10-2008, 03:56 AM
Sub UppdateraKlockan()
With ThisWorkbook.Sheets("INPUT").Range("P35")
.Value = Now
.NumberFormat = "hh:mm"
End With
K?rN?r = Now + TimeSerial(0, 1, 0)
Application.OnTime earliesttime:=K?rN?r, _
procedure:="UppdateraKlockan", schedule:=True
End Sub