嗯~ o(* ̄▽ ̄*)o,希望楼主不要介意,用数组写了下,应该比直接操作单元格快一点儿吧...
[Visual Basic] 纯文本查看 复制代码 Option Explicit
Sub emmmm()
Dim nR%, r%, dm$, url$, t
Dim arr, ssr
t = Timer
Application.ScreenUpdating = False
'==================================================================
With Sheet3
arr = .Range("a1").CurrentRegion
arr(1, 2) = Format(Now, "mm-dd") '更新时间
arr(1, 3) = Format(Now, "hh:mm")
For r = 3 To UBound(arr)
dm = arr(r, 1)
If left(dm, 1) = 6 Or dm = "000001" Then
url = "http://qt.gtimg.cn/q=sh" & dm '上交所
Else
url = "http://qt.gtimg.cn/q=sz" & dm '深交所
End If
With CreateObject("msxml2.xmlhttp")
.Open "GET", url, False
.send
ssr = Split(.responseText, "~")
If UBound(ssr) > 3 Then
arr(r, 2) = ssr(1): arr(r, 3) = ssr(3): arr(r, 5) = ssr(32): arr(r, 6) = ssr(4)
arr(r, 7) = ssr(5): arr(r, 8) = ssr(33): arr(r, 9) = ssr(34): arr(r, 10) = ssr(47)
arr(r, 11) = ssr(48): arr(r, 12) = ssr(38): arr(r, 13) = ssr(43): arr(r, 14) = ssr(6)
arr(r, 15) = ssr(39): arr(r, 16) = ssr(44): arr(r, 17) = ssr(45): arr(r, 18) = ssr(46)
arr(r, 4) = ssr(31)
If arr(r, 4) > 0 Then
With Range("d" & r & ":e" & r).Font
.Color = vbRed
.Bold = True
End With
Else
With Range("d" & r & ":e" & r).Font
.Color = vbGreen
.Bold = True
End With
End If
End If
End With
Next
.Range("a1").Resize(UBound(arr), UBound(arr, 2)) = arr
End With
Application.ScreenUpdating = True
MsgBox "又赚了一个亿呀,仅耗时:" & Format(Timer - t, "0.00秒"), 64, "WatchMen温馨提示:"
End Sub
|