回復 1#jiuhtsair
Private Sub ExeSelf()
On Error Resume Next
i = i + 1
If i = 58 Then '*至少要執行 ExeSelf 58次
Sheets(2).Cells(j, 1) = Time
Sheets(2).Cells(j, 2) = O
Sheets(2).Cells(j, 3) = H
Sheets(2).Cells(j, 4) = L
Sheets(2).Cells(j, 5) = C
Sheets(2).Cells(j, 6) = V
j = j + 1
i = 0: V = 0
'可是這裡 i 歸零了 : 那前面的 If i = 58 Then 又要等執行 ExeSelf 58次
O = Sheets(1).Cells(2, 2)
V = V + Sheets(1).Cells(2, 4)
H = O: L = O: C = O
Else
'以下判斷迴圈讓投資權重與投資標的物名稱設定,僅執行一次
C = Sheets(1).Cells(2, 2)
If C > H Then H = C
If C < L Then L = C
V = V + Sheets(1).Cells(2, 4)
' Sheets(2).Cells(i, 1) = Sheets(1).Cells(2, 2)
End If
Application.OnTime Now + TimeValue("00:00:01"), "ThisWorkBook.ExeSelf"
End Sub作者: jiuhtsair 時間: 2012-1-29 12:36