如何在EXCEL紀錄DDE的資料 - 財經

By Lucy
at 2008-07-31T16:58
at 2008-07-31T16:58
Table of Contents
最近剛好在玩這個
比較簡單的方法就設個timer
先在vba建立模組 然後加入下面幾個副程式
------------------------------------
Sub Schedule()
DoEvents
If Sheet2.Cells(2, 1) = 1 Then '當這個欄位值為1的時候開始紀錄
Call record '把DDE值抓到EXCEL的副程式
Call timer_Start 'timer開始
End If
End Sub
-------------------------------------
Sub timer_Start() '開始timer 每秒call Schedule一次
Application.OnTime Now + TimeValue("00:00:01"), "Schedule", Schedule:=True
End Sub
-------------------------------------
Sub timer_Stop()
On Error Resume Next '停止timer
Application.OnTime Now + TimeValue("00:00:01"), "Schedule", Schedule:=False
End Sub
-------------------------------------
Sub record() '紀錄DDE資料的副程式
Sheet2.Cells(2, 2) = Sheet2.Cells(2, 2) + 1 '這欄用來記錄現在行數
Sheet2.Cells(Sheet2.Cells(2, 2), 3) = Sheet1.Cells(1, 1)
'假設DDE要記錄的值在 Sheet1的(1,1)這個欄位
'將這資料存在 Sheet2中
End Sub
-------------------------------------
自己改掉上面寫的欄位成你要的就ok啦
要記得先將資料表中 Sheet2.Cells(2, 2), Sheet2.Cells(2, 1) 這兩個欄位給 0
不過話說這樣出來的資料量會很龐大喔......XD
※ 引述《anygod (GDP)》之銘言:
: ※ 引述《sesee (小七)》之銘言:
: : 大家好
: : 請問如果我想紀錄EXCEL裡DDE的資料
: : 例如A1 是隨時變動的DDE值
: : 從8:45:00 每隔1秒鐘紀錄在B1 B2 B3.........
: : 這樣的VBA要怎麼寫呢?
: : 我試過修改別人的VBA 可是跑不出來
: : 偵錯也不知道哪邊有錯誤
: : 謝謝回答 ^^
: 有VBA嗎? 可以寄給我看看嗎?
: 我目前也再弄DDE設定一些模型 但是VBA不熟
--
第一次學攝影就上手.....(嗎??)
http://www.wretch.cc/album/steam
--
Tags:
財經
All Comments

By Robert
at 2008-08-02T06:13
at 2008-08-02T06:13

By Skylar DavisLinda
at 2008-08-05T07:30
at 2008-08-05T07:30

By Donna
at 2008-08-08T19:07
at 2008-08-08T19:07

By Doris
at 2008-08-10T11:14
at 2008-08-10T11:14
Related Posts
尋找有興趣一同研究TS和HTS的同好

By Edward Lewis
at 2008-07-29T14:37
at 2008-07-29T14:37
有關TS的回測資料來源

By Olive
at 2008-07-28T23:23
at 2008-07-28T23:23
如何在EXCEL紀錄DDE的資料

By Puput
at 2008-07-27T18:34
at 2008-07-27T18:34
關於HTS最大評價損失幅。

By Eartha
at 2008-07-26T16:39
at 2008-07-26T16:39
關於HTS最大評價損失幅。

By Quintina
at 2008-07-26T14:10
at 2008-07-26T14:10