Any errors in this?
Ok ive got some macro code here, wondering if anyone could help me find any
errors, because i cant:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = False
With Target
If .Address = "$AA$10" Then
If .Value = "1" Then
StartTimer
End If
End If
End With
ws_exit:
Application.EnableEvents = True
End Sub
Public RunWhen As Double
Public Const cRunIntervalSeconds = 30
Public Const cRunWhat = "Start2"
Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime earliesttime:=RunWhen, procedu=cRunWhat, _
schedule:=True
End Sub
Sub Start2()
Range("Z11").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-4]=RC[-12], 2, 0)+1"
Range("Z12").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-4]=RC[-12], 2, 0)+1"
Range("Z13").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-4]=RC[-12], 2, 0)+1"
Range("Z14").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-4]=RC[-12], 2, 0)+1"
Range("Z15").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-4]=RC[-12], 2, 0)+1"
Range("Z16").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-4]=RC[-12], 2, 0)+1"
Range("Z17").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-4]=RC[-12], 2, 0)+1"
Range("Z18").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-4]=RC[-12], 2, 0)+1"
Range("AA18").Select
ActiveCell.FormulaR1C1 = "=1"
End Sub
Basically what it does it wait until i put a 1 in a cell, then starts a
timer for 30 seconds, which then adds a load of 1s to other cells.....
i know the coding for the timer and sub start2 are ok on their own, so i
dont think there is a problem there, it is only the top part i think where it
specifies to carry out the macro if the cell value of AA10 changes to 1...
can anyone spot anything ive done wrong?
|