如何制作一个实时统计股票的excel,求高手指点

发布网友

我来回答

4个回答

热心网友

热心网友

刚好前段时间写了一个,小修改一下就可以给你用了。

【假设前提】你的股票代码都在A列,并且是 xxxxxx.sh(或者sz)的格式

Sub gpAPI() '【注意】Excel中,Alt+F11,插入,模块,粘贴这段代码,然后F5
On Error Resume Next
Dim URL As String, HttpReq As Object
Dim StrText As String, Tbox As String

Let URL = "http://qt.gtimg.cn/q=s_": Set HttpReq = CreateObject("MSXML2.XMLHTTP.3.0")
    
i = 3

Dim Rng As Range
    Do While Range("A" & i) <> ""
        Set Rng = Range("A" & i)
            url_right = Right(Rng, 2) & Left(Rng, 6)
   
        With HttpReq
            .Open "GET", URL & url_right, False
            .send
            StrText = .responseText
            If .Status = 200 Then
                StrText = .responseText
            Else: Tbox = Tbox & Chr(13) & "Error - Connection timed out"
            End If
        End With
        
        temp = cut(StrText) '转码、截字符串、清洗替换
    
        Cells(i, 2).Value = Split(temp, "~")(1) '取数组写入列
        Cells(i, 3).Value = Split(temp, "~")(3)
    
        i = i + 1
    Loop
    
Cells(i, 2) = "" & " " & Now
End Sub

Function cut(str As String) '截取字符串并替换指定字符
    cut = Replace(str, Chr(10), "")      '替换指定字符
    cut = Replace(cut, ";", "")
    cut = Replace(cut, """", "")    '替换指定字符
    If cut Like "*pv_none_match=1*" Then cut = "~N/A" 'Error02 - No matching item
End Function

热心网友

想法挺好,但是感觉没啥用啊,另外股票软件可能不够直观但是这个功能也有。

热心网友

这是用股票分析软件来实现的,要是用excel表来实现除非你有股票软件的开源码,来实现嵌入式函数对接,不过太专业了,我的水平肯定不行

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com