Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 3790|回复: 0

VBA代码出错91

[复制链接]
发表于 2019-7-4 20:49 | 显示全部楼层 |阅读模式
1学分
本帖最后由 a316667229 于 2019-7-12 06:59 编辑

以下代码运行就出错,那位大师帮我修改一下呢
Sub getResource()
    Columns("A:G").ClearContents
    Set HTML = CreateObject("htmlfile")
    With CreateObject("msxml2.xmlhttp")
        Url = "http://live.win007.com/index2in1.aspx?id=8"
        .Open "get", Url, False
        .send
        HTML.body.innerhtml = StrConv(.responsebody, vbUnicode)
        Cells(1, 2) = HTML.body.document.getElementById("notice_Ddl").DefaultValue
        Set tr = HTML.all.tags("tr")
        j = 1
        For r = 0 To tr.Length - 1
            If Val(tr(r).Cells(0).innertext) + 1 = j Then
                j = j + 1
                Cells(j, 1) = tr(r).Cells(0).innertext
                Cells(j, 2) = tr(r).Cells(1).innertext
                Cells(j, 3) = tr(r).Cells(2).innertext
                Cells(j, 4) = tr(r).Cells(6).innertext
                Cells(j, 5) = tr(r).Cells(8).innertext
            End If
        Next
    End With

End Sub

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-3-29 20:02 , Processed in 0.270716 second(s), 8 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表