|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
老师,下面这个代码在打开EXCE后第1次可以刷新,第2次后刷新就还是老数据,能否怎样改一下呢?
另外:直接用浏览器打开:http://hqdigi2.eastmoney.com/EM_ ... page=1&style=33" 这个后,又可以刷新1次,是啥原因呢
Option Explicit
Sub Test()
Dim tmp() As String, i As Long, arr() As String, xmlhttp As Object, N As Long
Sheets("east").Select
Cells.Select
Selection.ClearContents
'[A1].CurrentRegion.Clear
'[a1:ae1] = Split("1a,代码,股票名称,昨收,今开,最新价,最高,最低,成交额,成交量,涨跌额,涨跌幅,均价,振幅,委比,委差,现手,内盘,外盘,20t,21u,5分钟涨跌幅,量比,换手,市盈,26z,27aa,28ab,更新时间,30ad,31ae", ",")
Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
With xmlhttp
.Open "get", "http://hqdigi2.eastmoney.com/EM_Quote2010NumericApplication/index.aspx?type=s&sortType=C&sortRule=-1&pageSize=5000&page=1&style=33", False
.send
tmp() = Split(Split(Split(Replace(.responsetext, """,""", ","), "{rank:[""")(1), """]")(0), ",")
End With
ReDim arr(UBound(tmp) \ 31, 30)
For i = 0 To UBound(tmp)
arr(i \ 31, i Mod 31) = tmp(i)
Next
[a2].Resize(UBound(arr, 1) + 1, UBound(arr, 2) + 1) = arr
[a:ae].Columns.AutoFit
Union(Columns(1), Columns(20), Columns(21), Columns(26), Columns(27), Columns(28), Columns(30), Columns(31)).ColumnWidth = 0
Erase tmp
Erase arr
Set xmlhttp = Nothing
'MsgBox "Ok"
End Sub |
|