示例代码:
vba
Sub UpdateWebData()
Dim http As Object
Dim html As Object
Dim table As Object
Dim row As Object
Dim cell As Object
Dim ws As Worksheet
Dim i As Integer, j As Integer
' 解析 HTML
Set html = CreateObject(htmlfile)
html.body.innerHTML = http.responseText
' 获取表格
Set table = html.getElementsByTagName(table)(0)
' 清空现有数据
ws.Cells.Clear
' 写入新数据
For i = 0 To table.Rows.Length 1
For j = 0 To table.Rows(i).Cells.Length 1
ws.Cells(i + 1, j + 1).Value = table.Rows(i).Cells(j).innerText
Next j
Next i
End Sub