My goal: Check if value exists, if the value not exists add at the end of column A. If the value exists skip the ID and check the next value.
Actual result: The IDs will be added at the end of line A neverthelesss if the value exists or not. Therfore I get duplicates.
I tried with "if" but I get an error.
My coding:
Option Explicit
Sub ExposeID()
Dim browser As Object 'Aufnehmen der verwendeten Instanz des Browsers (Internet Explorer)
Dim knotenAst As Object 'Aufnehmen einer HTML Struktur aus dem Browser Dokument
Dim n As Integer
Dim url As String 'Aufnehmen der auszulesenden Adresse
Dim ExposeID As String
Dim letztezeile As Integer
Dim nodeList As Object, i As Long
Set browser = CreateObject("internetexplorer.application")
browser.Visible = False
For n = 0 To 1
url = "https://www.immobilienscout24.de/Suche/de/niedersachsen/oldenburg-oldenburg/haus-kaufen?pagenumber=" & n + 1
browser.navigate url
Do Until browser.readyState = 4: DoEvents: Loop
letztezeile = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
Set nodeList = browser.document.querySelectorAll(".result-list__listing[data-id]")
For i = 0 To nodeList.Length - 1
''' HERE IS THE PROBLEM '''
If nodeList.Item(i).getAttribute("data-id") <> Cells.Range("A:A") Then
Cells(letztezeile + i + 1, 1) = nodeList.Item(i).getAttribute("data-id")
Else
End If
Next i
Next n
Set nodeList = Nothing
browser.Quit
End Sub
Aucun commentaire:
Enregistrer un commentaire