当数据从 C4:C7 列的范围呈现时,此代码可以正常工作,但是我的工作表是使用 C4:K4 的一行中的数据设置的。我不能得到一行而不是一列来解决。有什么帮助吗?谢谢。
Sub RecordData()
Dim Interval As Double
Dim cel As Range, Capture As Range
Interval = 30 'Number of seconds between each recording of data
Set Capture = Worksheets("Sheet1").Range("C4:K4") 'Capture this row of data
With Worksheets("Sheet2") 'Record the data on this worksheet
Set cel = .Range("A2") 'First timestamp goes here
Set cel = .Cells(.Rows.Count, cel.Column).End(xlUp).Offset(1, 0)
cel.Value = Now
cel.Offset(0, 1).Resize(1, Capture.Cells.Count).Value = Application.Transpose(Capture.Value)
End With
NextTime = Now + Interval / 86400
Application.OnTime NextTime, "RecordData"
End Sub