简体   繁体   中英

Excel: record real time updating row to table

I have a real time updating row (A2:E2) on sheet1, and I'd like to record it every 5 seconds to a table on sheet2. The eventual goal is to graph it.

I tried this but I'm only getting the Data sheet to update on 1 row, failing to populate further.

Sub ValueStore()
    Dim dTime As Date
    Dim LastRow As Long
    LastRow = Sheets("Data").Range("A" & Rows.Count).End(xlUp).Row + 1
    Range("A2:E2").Copy Destination:=Sheets("Data").Range("A" & LastRow)
    Call StartTimer
End Sub

Sub StartTimer()
    dTime = Now + TimeValue("00:00:05")
    Application.OnTime dTime, "ValueStore", Schedule:=True
End Sub

Sub StopTimer()
    On Error Resume Next
    Application.OnTime dTime, "ValueStore", Schedule:=False
End Sub

Sub DeleteData()
    Sheets("Data").Range("A2:E1000").Delete
End Sub

try using a loop and a wait() method before executing next loop...

    sub valuestore()
    for (loop range)
      LastRow = Sheets("Data").Range("A" & Rows.Count).End(xlUp).Row + 1
      Range("A2:E2").Copy Destination:=Sheets("Data").Range("A" & LastRow)
      application.wait now()+"00:00:05"
      next loop_variable
      end sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM