How can I correct this VBA to properly scrape the owner’s name, given the property address in column A?

Hi I am trying use VBA to look property tax records off of. I’d like to return the owner of a property in column B, given the address is column A.

https://publictax.smith-county.com/Search/Results?

The code I’ve developed will go to the above URL and successfully:

  1. Change the drop down on the left to “Property Address”
  2. Click the search button on the right

My code is having difficulty returning to Column B the owner’s full name on the next page.

Query.SearchField=5&Query.SearchText=2115+Crestwood+Dr&Query.SearchAction=&Query.IncludeInactiveAccounts=False&Query.PayStatus=Both
Sub GetOwnerNames()
Dim IE As Object
Dim ws As Worksheet
Dim lastRow As Long
Dim address As String
Dim ownerName As String
Dim i As Long
Dim cardBodies As Object
Dim cardBody As Object
Dim smallElements As Object
Dim smallElement As Object
Dim locationFound As Boolean
Dim ownerElements As Object
Dim ownerElement As Object
Dim siblingElement As Object

' Create a new Internet Explorer instance
On Error Resume Next
Set IE = CreateObject("InternetExplorer.Application")
If IE Is Nothing Then
    MsgBox "Could not create Internet Explorer instance", vbCritical
    Exit Sub
End If
On Error GoTo 0

IE.Visible = True ' Set to True if you want to see the IE window

' Set the worksheet and find the last row with data in column A
Set ws = ThisWorkbook.Sheets("Sheet1") ' Change to your sheet name
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row

For i = 2 To lastRow ' Assuming the first row is a header
    address = ws.Cells(i, 1).Value
    If address <> "" Then
        ' Navigate to the search page
        IE.Navigate "https://publictax.smith-county.com/search"
        Do While IE.Busy Or IE.readyState <> 4: DoEvents: Loop

        ' Select "Property Address" from the dropdown
        Set DropDown = IE.document.getElementById("Query.SearchField")
        If DropDown Is Nothing Then
            MsgBox "Could not find dropdown element", vbCritical
            GoTo Cleanup
        End If
        DropDown.Value = 5 ' Value for "Property Address"
        DropDown.FireEvent "onchange"
        Do While IE.Busy Or IE.readyState <> 4: DoEvents: Loop

        ' Find the search box, input the address, and submit the search
        Set searchBox = IE.document.getElementById("Query.SearchText")
        If searchBox Is Nothing Then
            MsgBox "Could not find search box element", vbCritical
            GoTo Cleanup
        End If
        searchBox.Value = address
        Do While IE.Busy Or IE.readyState <> 4: DoEvents: Loop

        ' Click the search button
        Set searchButton = IE.document.querySelector("button.btn.btn-primary.col[type=submit]")
        If searchButton Is Nothing Then
            MsgBox "Could not find search button element", vbCritical
            GoTo Cleanup
        End If
        searchButton.Click
        Do While IE.Busy Or IE.readyState <> 4: DoEvents: Loop

        ' Wait for the results to load completely
        Application.Wait Now + TimeValue("00:00:10")

        ' Extract elements to find "Property Location" and "Owner Name"
        ownerName = "Not Found"
        Set cardBodies = IE.document.querySelectorAll("div.card-body")
        If cardBodies Is Nothing Then
            MsgBox "Could not find card-body elements", vbCritical
            GoTo Cleanup
        End If

        For Each cardBody In cardBodies
            locationFound = False
            Set smallElements = cardBody.getElementsByTagName("small")
            For Each smallElement In smallElements
                If InStr(Trim(smallElement.innerText), "Property Location") > 0 Then
                    Debug.Print "Property Location found: " & Trim(smallElement.innerText)
                    If Not smallElement.NextElementSibling Is Nothing Then
                        If InStr(Trim(smallElement.NextElementSibling.innerText), address) > 0 Then
                            Debug.Print "Address matched: " & Trim(smallElement.NextElementSibling.innerText)
                            locationFound = True
                            Exit For
                        End If
                    End If
                End If
            Next smallElement

            ' If the property location is found, get the owner name
            If locationFound Then
                Set ownerElements = cardBody.getElementsByTagName("strong")
                For Each ownerElement In ownerElements
                    If Trim(ownerElement.innerText) <> "" And Trim(ownerElement.innerText) <> "Account Number" And _
                       Trim(ownerElement.innerText) <> "Total Due" And Trim(ownerElement.innerText) <> "Owner Name" And _
                       Trim(ownerElement.innerText) <> "Type" And Trim(ownerElement.innerText) <> "Property Location" Then
                        ownerName = ownerElement.innerText
                        Exit For
                    End If
                Next ownerElement
                Exit For
            End If
        Next cardBody

        ' Write the owner name back to the worksheet
        ws.Cells(i, 2).Value = ownerName
    End If
Next i

Cleanup:
‘ Clean up
On Error Resume Next
IE.Quit
Set IE = Nothing
On Error GoTo 0

MsgBox "Owner names have been updated.", vbInformation

End Sub

I’ve tried using AI to help correct the code, however The VBA either returns “not found”, or it will successfully, but incorrectly grab the account number that you see in the screenshot below. How can I adjust this VBA to grab the name “Walker Janis Kimberly” and past it in column B, before moving onto the next address?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật