返回列表 上一主題 發帖

DDE 擷取分鐘最高最低

本帖最後由 stillfish00 於 2013-6-21 11:20 編輯

回復 1# vzcen
沒用過DDE,僅供參考。
  1. Private gbStart As Boolean
  2. Private recTime
  3. Private recValue
  4. Private Sub Worksheet_Calculate()
  5.     Dim ddeValue
  6.    
  7.     If gbStart Then
  8.         ddeValue = [B6].Value
  9.         If IsEmpty(recValue) Then recTime = Time: recValue = ddeValue
  10.         
  11.         If Minute(recTime) = Minute(Time) Then
  12.             If ddeValue > recValue Then recTime = Time: recValue = ddeValue
  13.         Else
  14.             '紀錄時間在D欄最後一列下方
  15.             Cells(Rows.Count, "D").End(xlUp).Offset(1).Value = recTime
  16.             '紀錄價格在E欄最後一列下方
  17.             Cells(Rows.Count, "E").End(xlUp).Offset(1).Value = recValue
  18.             recTime = Time: recValue = ddeValue
  19.         End If
  20.     End If
  21.    
  22. End Sub
  23. '可建立按鈕開始或結束
  24. Private Sub StartRecordData()
  25.     gbStart = True
  26. End Sub
  27. Private Sub StopRecordData()
  28.     gbStart = False
  29.     recTime = Empty
  30.     recValue = Empty
  31. End Sub
複製代碼

TOP

        靜思自在 : 要批評別人時,先想想自己是否完美無缺。
返回列表 上一主題