標題:
[發問]
新年之後無法自動更新股價的問題
[打印本頁]
作者:
netfish777
時間:
2019-1-7 19:52
標題:
新年之後無法自動更新股價的問題
這是我把網路高手分享的EXCEL拼湊起來,紀錄配股配息的EXCEL
原本按"一覽表"上方按鈕可一鍵自動更新股價,
可是元旦之後會出現錯誤訊息而只能更新第一檔股票,
懇請各位前輩幫我看看要如何更正好嗎?非常感謝
作者:
f3202
時間:
2019-1-9 10:28
Sub 擷取資料()
Dim ReTxt, i&, ARR, BRR(9), V As Currency, GetTime$
uTxtStr = ""
Call 取得網頁原始碼: If uTxtStr = "" Then Exit Sub
'-----------------------------------------------------
GetStr = ""
ST1 = "href=""/q/bc?s=" & uRng & """>"
ST2 = "<a href=""/q/ts?s=" & uRng & """>成交明細</a>"
GetStr = 擷取文字碼(uTxtStr, ST1, ST2): If GetStr = "" Then Exit Sub
ReTxt = Array("</td>", "", "</b>", "", "△", "", "▽", "-", "▲", "", "▼", "-", ",", "", ">", String(20, " "))
For i = 0 To UBound(ReTxt) Step 2
GetStr = Replace(GetStr, ReTxt(i), ReTxt(i + 1))
Next i
'-----------------------------------------------------
ARR = Split(GetStr, Chr(10))
For i = 0 To UBound(ARR)
If i = 0 Then BRR(i) = Trim(Mid(Replace(ARR(i), "<", String(10, " ")), Len(uRng) + 1, 10))
If i > 1 And i < 11 Then BRR(i - 1) = Trim(Right(ARR(i), 20))
Next
Range(uRng(1, 2), uRng(1, 11)).Value = BRR
'-----------------------------------------------------
ST1 = "<span class=""ssbodyw"">"
ST2 = "</span></div></td>"
GetTime = 擷取文字碼(uTxtStr, ST1, ST2)
uRng(1, 12) = Time ' CDate(Mid(Left(GetTime, 16), 12))
End Sub
試試
作者:
netfish777
時間:
2019-1-9 14:17
回復
2#
f3202
可以了,我對VBA只有略懂皮毛,實在是看不懂哪裡出錯
非常感恩前輩幫忙
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)