Good day everyone. I have been using a macro to pull data regarding 3 seperate forms from a website table, and was needing help finding a way to find the document with the most recent date. Here is what the table looks like. on the website.

http://www.pangaeadata.com/OCC_Files...api=3511922067

Typically the order the forms go in are 1000,1001A,1002A. So a 1000 form is filed, and then a person will file a 1001A, and once completed they turn in a 1002A. This might happen for the same well numerous times. By the way this info pertains to oil and gas wells. The reason you have more than one is that someone might go back to an old well and recomplete it to see if they can pull more fluid/gas out of the ground. So when this happens a new cycle of forms starts. I would like to figure out how to only find the most recent document for each well in my list of urls like the one above. There are other forms on the website, but i am only concerned with the most recent one. Is there a way I would be able to do this easily? I set up my macro to search heirarchily, but i realized that the most recent document of either a 1000,1001A,or 1002A is all I really need. Any help would be much appreciated. Let me know if this makes sense to anyone or if you need more info from me. I posted the code I am using already below.


Function GetWellData(url As String) As Variant

    Dim arr(1 To 3)
    Dim Doc As Object
    Dim Href As String
    Dim oTable As Object
    Dim PageSource As String
    Dim sLookup As String
    Dim x As Long
        
       
        With CreateObject("msxml2.xmlhttp")
            .Open "GET", url, False
            .send
            PageSource = .responseText
        End With
        
          ' Create the HTML Document object.
            Set Doc = CreateObject("htmlfile")
            Doc.Open url:="text/html", Replace:=True
            Doc.write PageSource
        
            Set oTable = Doc.getElementById("DataGrid")
                
            For x = 2 To oTable.Rows.Length - 1
                If oTable.Rows(x).Cells(0).ChildNodes(0).nodeName = "A" Then
                    Href = oTable.Rows(x).Cells(0).ChildNodes(0).Href
                
                    sLookup = oTable.Rows(x).Cells(1).innerText
                    Select Case sLookup
                    Case Is = "1000"
                        If Val(sLookup) > Val(arr(1)) Then
                            arr(1) = sLookup
                            arr(2) = oTable.Rows(x).Cells(6).innerText
                        End If
                    Case Is = "1001A"
                        If Val(sLookup) > Val(arr(1)) Then
                            arr(1) = sLookup
                            arr(2) = oTable.Rows(x).Cells(6).innerText
                        End If
                    Case Is = "1002A"
                        If Val(sLookup) > Val(arr(1)) Then
                            arr(1) = sLookup
                            arr(2) = oTable.Rows(x).Cells(6).innerText
                            arr(3) = Href
                        End If
                    End Select
                End If
            Next x
    
      GetWellData = arr
      
End Function