- 帖子
- 8
- 主題
- 1
- 精華
- 0
- 積分
- 14
- 點名
- 0
- 作業系統
- WIN7
- 軟體版本
- Office2003
- 閱讀權限
- 10
- 性別
- 男
- 註冊時間
- 2012-8-7
- 最後登錄
- 2012-10-18
|
7#
發表於 2012-8-23 22:20
| 只看該作者
回復 6# c_c_lai
您好~
我的只是用很簡單的資料去抓取一些相關資料只有設定每分鐘抓取DDE儲存格的資料來做紀錄
您看一下
Option Explicit
Dim LastMin As Integer
Private Sub Workbook_Open()
Sheets("策略記錄").Cells(4, 2) = 12
LastMin = Minute(Time)
Call Timer
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.OnTime Now + TimeValue("00:00:01"), "ThisWorkbook.Timer", , False
End Sub
Public Sub Timer()
Dim Pos As Integer, i As Integer, RangeStr As String
On Error Resume Next
Application.OnTime Now + TimeValue("00:00:01"), "ThisWorkbook.Timer" '每秒顯示
Sheets("策略記錄").Cells(1, 1) = Time '將時間show至策略的a1欄位
Dim HHMM As Integer
HHMM = Hour(Time) * 100 + Minute(Time)
If (HHMM < 830 Or HHMM > 1346) Then Exit Sub '營業時間才執行
If Minute(Time) <> LastMin Then '開始後做
With Sheets("策略記錄")
.Cells(4, 2) = .Cells(4, 2) + 1 '將變動行號加一行
Pos = .Cells(4, 2)
.Cells(Pos, 1) = Time
.Cells(Pos, 2) = .Cells(2, 2)
.Cells(Pos, 3) = .Cells(2, 3)
.Cells(Pos, 4) = .Cells(2, 4)
.Cells(Pos, 5) = .Cells(2, 5)
.Cells(Pos, 6) = .Cells(2, 6)
.Cells(Pos, 7) = .Cells(2, 7)
.Cells(Pos, 8) = .Cells(2, 8)
.Cells(Pos, 9) = .Cells(2, 9)
.Cells(Pos, 10) = .Cells(2, 10)
.Cells(Pos, 11) = .Cells(2, 11)
.Cells(Pos, 12) = .Cells(2, 12)
.Cells(Pos, 13) = .Cells(2, 13)
.Cells(Pos, 14) = .Cells(2, 14)
.Cells(Pos, 15) = .Cells(2, 15)
.Cells(Pos, 16) = .Cells(2, 16)
.Cells(Pos, 17) = .Cells(2, 17)
End With
LastMin = Minute(Time)
End If
End Sub
像您貼的檔案,我就真的不知道還要修改哪邊,才能自動寫入了,煩請您教導一下(因為我完全不懂VBA編碼........請別見笑)
另外想向您請教一下,您有6月以前的台指奇多空力道的資料及成交價ㄇ??
感謝您 |
|