excel VB宏的求助,占用一下这里
请教一下大神们,如果单元格的代码,如首字符是6(是字符串,不是数字),则URL = "http://qt.gtimg.cn/q=sh" & Cells(r, 1).Value,否则URL = "http://qt.gtimg.cn/q=sz" & Cells(r, 1).Value 以下为需要更改的代码 Sub test() For r = 3 To Range("A1").CurrentRegion.Rows.Count URL = "http://qt.gtimg.cn/q=sz" & Cells(r, 1).Value With CreateObject("msxml2.xmlhttp") .Open "GET", URL, False .send sp = Split(.responsetext, "~") If UBound(sp) > 3 Then Cells(r, 3).Value = sp(3) Cells(r, 4).Value = Format(sp(30), "0000-00-00 00:00:00") Else Cells(r, 3).Value = "证券代码错啦!" End If End With Next End Sub 这个代码要怎么改
jsl8071808 发布于 2018-11-13 16:49
1min目标场景问卷 立即参与
回答问题
悬赏:0 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共1回答
最佳回答
4
touyuan001Lv6中级互助
发布于2018-11-13 17:47

Sub test()

For r = 3 To Range("A1").CurrentRegion.Rows.Count

URL1 = "http://qt.gtimg.cn/q=sh" & Cells(r, 1).Value

URL2 = "http://qt.gtimg.cn/q=sz" & Cells(r, 1).Value

If Left(Cells(r, 1).Value, 1) = "6" Then

Cells(r, 3).Value = URL1

Else

Cells(r, 3).Value = URL2

End If

Next

End Sub


  • 2关注人数
  • 514浏览人数
  • 最后回答于:2018-11-13 17:47
    请选择关闭问题的原因
    确定 取消
    返回顶部