VBA Help

Discussion in 'Trading Software' started by Grant, Oct 17, 2007.

  1. Grant


    I need to modify the following code to enable update on a tick-by-tick basis.

    I think the line

    RunWhen = Now + TimeValue("00:00:01")

    (set at 1-second intervals) is what needs to changed. Any advice appreciated.

    Thank you.


    Public RunWhen As Double
    Public Const cRunWhat = "MyFunc"

    Sub StartTimer()
    RunWhen = Now + TimeValue("00:00:01")
    Application.OnTime earliesttime:=RunWhen, procedure:=cRunWhat, _
    End Sub

    Sub MyFunc()

    Dim row As Single

    row = ActiveSheet.Range("A65536").End(xlUp).row + 1
    Cells(row, 1).Value = Time()
    Cells(row, 2).Value = [A1].Value
    Cells(row, 3).Value = [B1].Value
    Cells(row, 4).Value = [C1].Value
    Cells(row, 5).Value = [D1].Value
    Cells(row, 6).Value = [E1].Value
    Cells(row, 7).Value = [F1].Value

    End Sub

    Sub StopTimer()
    On Error Resume Next
    Application.OnTime earliesttime:=RunWhen, _
    procedure:=cRunWhat, schedule:=False
    End Sub

    Sub ClearArea()
    End Sub