+ Reply to Thread
Results 1 to 3 of 3

Copy real time data that changes every sec to new row according timestamp (using macro)

  1. #1
    Registered User
    Join Date
    06-24-2021
    Location
    Gurgaon
    MS-Off Ver
    2016, 2019
    Posts
    1

    Copy real time data that changes every sec to new row according timestamp (using macro)

    I created this sub that runs every 25milliseconds.
    Sub ATimedRecalc()
    TRCopy
    Application.OnTime Now + TimeValue("00:00:25"), "ATimedRecalc"
    'Application.RTD.RefreshData
    End Sub


    Below sub is used to copy data but I am finding error on the first line of code.
    The error is 424- object required.
    There are values in Q3 to Q100 that changes every few milliseconds.
    From AA2 to AA26 below is timestamps which i want to store.
    Sub TRCopy()

    'Copy AT Excel
    Dim TRPutOI As String
    TRPutOI = "Q3:Q100"

    If OC.Range("AA2").Value = Format(Now(), "hh:mm:00") Then --------error here in debugger
    If IsEmpty(OC.Range("AA3").Value) Then
    OC.Range("AA3:AA100").Value = OC.Range(TRPutOI).Value
    End If
    ElseIf OC.Range("AB2").Value = Format(Now(), "hh:mm:00") Then
    If IsEmpty(OC.Range("AB3").Value) Then
    OC.Range("AB3:AB100").Value = OC.Range(TRPutOI).Value
    End If
    ElseIf OC.Range("AC2").Value = Format(Now(), "hh:mm:00") Then
    If IsEmpty(OC.Range("AC3").Value) Then
    OC.Range("AC3:AC100").Value = OC.Range(TRPutOI).Value
    End If
    ElseIf OC.Range("AD2").Value = Format(Now(), "hh:mm:00") Then
    If IsEmpty(OC.Range("AD3").Value) Then
    OC.Range("AD3:AD100").Value = OC.Range(TRPutOI).Value
    End If
    ElseIf OC.Range("AE2").Value = Format(Now(), "hh:mm:00") Then
    If IsEmpty(OC.Range("AE3").Value) Then
    OC.Range("AE3:AE100").Value = OC.Range(TRPutOI).Value
    End If
    ElseIf OC.Range("AF2").Value = Format(Now(), "hh:mm:00") Then
    If IsEmpty(OC.Range("AF3").Value) Then
    OC.Range("AF3:AF100").Value = OC.Range(TRPutOI).Value
    End If
    ElseIf OC.Range("AG2").Value = Format(Now(), "hh:mm:00") Then
    If IsEmpty(OC.Range("AG3").Value) Then
    OC.Range("AG3:AG100").Value = OC.Range(TRPutOI).Value
    End If
    ElseIf OC.Range("AH2").Value = Format(Now(), "hh:mm:00") Then
    If IsEmpty(OC.Range("AH3").Value) Then
    OC.Range("AH3:AH100").Value = OC.Range(TRPutOI).Value
    End If
    ElseIf OC.Range("AI2").Value = Format(Now(), "hh:mm:00") Then
    If IsEmpty(OC.Range("AI3").Value) Then
    OC.Range("AI3:AI100").Value = OC.Range(TRPutOI).Value
    End If
    ElseIf OC.Range("AJ2").Value = Format(Now(), "hh:mm:00") Then
    If IsEmpty(OC.Range("AJ3").Value) Then
    OC.Range("AJ3:AJ100").Value = OC.Range(TRPutOI).Value
    End If
    ElseIf OC.Range("AK2").Value = Format(Now(), "hh:mm:00") Then
    If IsEmpty(OC.Range("AK3").Value) Then
    OC.Range("AK3:AK100").Value = OC.Range(TRPutOI).Value
    End If
    ElseIf OC.Range("AL2").Value = Format(Now(), "hh:mm:00") Then
    If IsEmpty(OC.Range("AL3").Value) Then
    OC.Range("AL3:AL100").Value = OC.Range(TRPutOI).Value
    End If
    ElseIf OC.Range("AM2").Value = Format(Now(), "hh:mm:00") Then
    If IsEmpty(OC.Range("AM3").Value) Then
    OC.Range("AM3:AM100").Value = OC.Range(TRPutOI).Value
    End If
    ElseIf OC.Range("AN2").Value = Format(Now(), "hh:mm:00") Then
    If IsEmpty(OC.Range("AN3").Value) Then
    OC.Range("AN3:AN100").Value = OC.Range(TRPutOI).Value
    End If
    ElseIf OC.Range("AO2").Value = Format(Now(), "hh:mm:00") Then
    If IsEmpty(OC.Range("AO3").Value) Then
    OC.Range("AO3:AO100").Value = OC.Range(TRPutOI).Value
    End If
    ElseIf OC.Range("AP2").Value = Format(Now(), "hh:mm:00") Then
    If IsEmpty(OC.Range("AP3").Value) Then
    OC.Range("AP3:AP100").Value = OC.Range(TRPutOI).Value
    End If
    ElseIf OC.Range("AQ2").Value = Format(Now(), "hh:mm:00") Then
    If IsEmpty(OC.Range("AQ3").Value) Then
    OC.Range("AQ3:AQ100").Value = OC.Range(TRPutOI).Value
    End If
    ElseIf OC.Range("AR2").Value = Format(Now(), "hh:mm:00") Then
    If IsEmpty(OC.Range("AR3").Value) Then
    OC.Range("AR3:AR100").Value = OC.Range(TRPutOI).Value
    End If
    ElseIf OC.Range("AS2").Value = Format(Now(), "hh:mm:00") Then
    If IsEmpty(OC.Range("AS3").Value) Then
    OC.Range("AS3:AS100").Value = OC.Range(TRPutOI).Value
    End If
    ElseIf OC.Range("AT2").Value = Format(Now(), "hh:mm:00") Then
    If IsEmpty(OC.Range("AT3").Value) Then
    OC.Range("AT3:AT100").Value = OC.Range(TRPutOI).Value
    End If
    ElseIf OC.Range("AU2").Value = Format(Now(), "hh:mm:00") Then
    If IsEmpty(OC.Range("AU3").Value) Then
    OC.Range("AU3:AU100").Value = OC.Range(TRPutOI).Value
    End If
    ElseIf OC.Range("AV2").Value = Format(Now(), "hh:mm:00") Then
    If IsEmpty(OC.Range("AV3").Value) Then
    OC.Range("AV3:AV100").Value = OC.Range(TRPutOI).Value
    End If
    ElseIf OC.Range("AW2").Value = Format(Now(), "hh:mm:00") Then
    If IsEmpty(OC.Range("AW3").Value) Then
    OC.Range("AW3:AW100").Value = OC.Range(TRPutOI).Value
    End If
    ElseIf OC.Range("AX2").Value = Format(Now(), "hh:mm:00") Then
    If IsEmpty(OC.Range("AX3").Value) Then
    OC.Range("AX3:AX100").Value = OC.Range(TRPutOI).Value
    End If
    ElseIf OC.Range("AY2").Value = Format(Now(), "hh:mm:00") Then
    If IsEmpty(OC.Range("AY3").Value) Then
    OC.Range("AY3:AY100").Value = OC.Range(TRPutOI).Value
    End If
    End If


    1.png

  2. #2
    Forum Contributor
    Join Date
    05-09-2021
    Location
    Sweden
    MS-Off Ver
    Office 365
    Posts
    148

    Re: Copy real time data that changes every sec to new row according timestamp (using macro

    Hi there,

    Please put the code within code tags, and attach your excel file as well. This will make it easier to help.

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,445

    Re: Copy real time data that changes every sec to new row according timestamp (using macro

    The sheet variable OC does not seem to be defined or set.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Schedule copy real-time data as values to new sheet
    By gotroots in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-23-2020, 06:00 PM
  2. Refreshing Real-Time Data in Excel while macro is running?
    By aquixano in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-22-2019, 05:57 PM
  3. Real Timestamp and convert to workshift via an IF statement or other
    By tonytorero in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-14-2017, 07:21 PM
  4. How to Run a Macro Based on Change in a cell caused by incoming Real-Time Server Data
    By taxkinginc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-18-2016, 05:00 AM
  5. does formula exist to copy data to another worksheet in real time?
    By belinda_235 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-08-2015, 06:16 AM
  6. Replies: 1
    Last Post: 03-28-2014, 12:45 PM
  7. Trigger Macro on cell change by real time data
    By boesingen in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-04-2013, 04:22 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1