Ontime creating memory issues

yankee428

Active Member
Joined
Apr 12, 2004
Messages
348
I use OnTime to snapshot some cells with streaming data every min. I start it at 7am and it runs every min until 5pm
Code:
Sub MarketSnapshotAuto()
    Dim rngMyRng As Range
    Set rngMyRng = ThisWorkbook.Sheets("Market Snapshot").Range("Time")
    For Each cel In rngMyRng
        Application.OnTime cel, "MarketSnapshot"
    Next
End Sub
the MarketSnapshot process is listed below. It basically copies the data as values to a different range. Running it at 7am has no impact on my PC, but by 6pm it slows down my PC. My understanding of OnTime is that it will load up each loop into memory, then unwind/execute as time progresses. If this is the case, should performance improve over time, not decrease?
Code:
Sub MarketSnapshot()
    Dim SheetStart As String
    SheetStart = ActiveSheet.Name
    Application.ScreenUpdating = False
    Sheets("Market Snapshot").Select
    Range("SnapNum").Value = Range("SnapNum").Value + 1
    Calculate
    Range("SnapshotAbsLive").Copy
    Range("SnapshotAbs").Cells(1, 1) = Time
    Range("SnapshotAbs").Range(Cells(1, 2), Cells(1, 38)).PasteSpecial xlPasteValues
    'Range("SnapshotAbs").Cells(1, 39) = 0
    Range("SnapshotChangeLive").Copy
    Range("SnapshotChange").Cells(1, 1) = Time
    Range("SnapshotChange").Range(Cells(1, 2), Cells(1, 32)).PasteSpecial xlPasteValues
    Range("A1").Select
    Application.CutCopyMode = False
    Sheets(SheetStart).Select
    Application.ScreenUpdating = True
End Sub
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
figured it out. don't load each OnTime in a loop. Instead have the work routing launch itself on an OnTime event.
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,582
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top