从页面获取和比较数据

时间:2014-02-19 15:33:13

标签: excel vba excel-vba

我已从此页面获取价格表

http://www.kieskeurig.nl/objectief/canon/ef_100mm_f2_usm/prijzen/bezorgen/167557#prijzen

现在我需要比较列表中商店位置的位置和列表中的第1商店。

我有两段代码

Sub GetAllTables(doc As Object)

     ' get all the tables from a webpage document, doc, and put them in a new worksheet

    Dim ws As Worksheet
    Dim rng As Range
    Dim tbl As Object
    Dim rw As Object
    Dim cl As Object
    Dim tabno As Long
    Dim nextrow As Long
    Dim I As Long

    Set ws = Sheets("Sheet1")


    For Each tbl In doc.getElementsByTagName("TABLE")
        tabno = tabno + 1
        nextrow = nextrow + 1
        Set rng = ws.Range("B" & nextrow)
        rng.Offset(, -1) = "Table " & tabno
        For Each rw In tbl.Rows
            colno = 1
            For Each cl In rw.Cells
                If colno = 1 and nextrow > 1 then
                    Set classColl = doc.getElementsByClassName("shopLogoX")
                    Set imgTgt = classColl(nextrow - 2).getElementsByTagName("img")
                    rng.Value = imgTgt(0).getAttribute("alt")
                Else
                    rng.Value = cl.innerText
                End If
                Set rng = rng.Offset(, 1)
                I = I + 1
                colno = colno + 1
            Next cl
            nextrow = nextrow + 1
            Set rng = rng.Offset(1, -I)
            I = 0
        Next rw
    Next tbl

    ws.Cells.ClearFormats

End Sub

Dim i As Integer
Dim j As Integer
Dim k As String
Dim l As String
Dim m As Integer
i = 2
For i = 2 To 50 If Range("B" & i).Value = "Foto Konijnenberg" Then

Range("K2").Value = Range("F" & i).Value 

Exit For 

End If 

Range("L2").Value = i 

Range("M2").Value = Range("B2").Value 

Range("N2").Value = Range("F2").Value Next

我需要合并这两个代码并获得比较结果。

0 个答案:

没有答案