Sub 逐筆記錄()
Dim DSht As Worksheet, dEnd As Range
On Error GoTo 999
Set DSht = ThisWorkbook.Sheets(uRng.Text)
With DSht
.[B1] = uRng: .[D1] = uRng(1, 2): .[E1] = ""
Set dEnd = DSht.[A65536].End(xlUp)(2)
If dEnd.Row < 3 Then Set dEnd = DSht.[A3] If dEnd(0, 5) = uRng(1, 7) Then Exit Sub '加入這一行,當成交量未變動,不記錄!!!
dEnd.Resize(1, 5) = uRng(1, 3).Resize(1, 5).Value
If dEnd.Row > 3 Then dEnd(1, 6) = dEnd(1, 5) - dEnd(0, 5)
dEnd(1, 7).Value = CDate(Date + uTime)
End With
999: End Sub作者: chairles59 時間: 2016-4-3 23:51
準大大:
不好意思
可能我vba不是很強
如何更改手動更新全部也能把股票資料轉到另一個工作表
If uMode = 1 Then Call 逐筆記錄
把藍色部份去掉即可
Sub 更新全部()
Call 共用參照: If uRow <= 0 Then Exit Sub
uHead(0, 0) = "※更新中.............."
uHead(2, 12).Resize(uRow).ClearContents
For Each uRng In uClmnNo
uRng(1, 3).Resize(1, 10).ClearContents
If uRng = "" Then uRng(1, 2).ClearContents: GoTo 101
Call 擷取資料
If GetStr = "" Then uRng(1, 2).ClearContents: GoTo 101
'If uMode = 1 Then Call 逐筆記錄 '只在〔自動更新〕模式下才記錄
Beep
101: Next
uHead(0, 0) = "※更新時間:" & Format(Now, "yyyy/mm/dd hh:mm:ss")
ThisWorkbook.Save
End Sub
是不是這樣改手動更新全部也能把股票資料轉到另一個工作表
我試了按手動更新全部按鈕好像沒有反應
請大大在看哪裡有問題作者: 准提部林 時間: 2016-4-4 09:59
Sub 更新全部()
Call 共用參照: If uRow <= 0 Then Exit Sub
uHead(0, 0) = "※更新中.............."
uHead(2, 12).Resize(uRow).ClearContents
For Each uRng In uClmnNo
uRng(1, 3).Resize(1, 10).ClearContents
If uRng = "" Then uRng(1, 2).ClearContents: GoTo 101
Call 擷取資料
If GetStr = "" Then uRng(1, 2).ClearContents: GoTo 101