VLookup_HTML

Does a search in 1st column (< td tag) in an HTML table (< table tag), and return the value from corresponding column of Col_Index_Number in same row (Exactly as the famous vlookup, but works in HTML tables
With ability to do search as full word in 1st column, or partial word.
    Pass SearchMethod = 1 to find for Lookup_Item exactly, 2 if we want to find Lookup_Item as part of the full column, not exactly.
    Pass ReturnHTMLCode = 1 to return full content of said column including HTML tags, 2 to return innerHTML of that column without tags
Needs: CutString3(), Frequency(), RemoveHTMLTags()

CodeFunctionName
What is this?

Public

Tested

Original Work
Function VLookup_HTML(Lookup_Item, Lookup_Table_HTML, Col_Index_Number, SearchMethod, ReturnHTMLCode)
    ' Does a search in 1st column ( <td tag) in an HTML table ( <table tag), and return the value from corresponding column of Col_Index_Number in same row ( <tr tag)
    ' Exactly as the famous vlookup, but works in HTML tables
    ' With ability to do search as full word in 1st column, or partial word.
    '    Pass SearchMethod = 1 to find for Lookup_Item exactly, 2 if we want to find Lookup_Item as part of the full column, not exactly.
    '    Pass ReturnHTMLCode = 1 to return full content of said column including HTML tags, 2 to return innerHTML of that column without tags
    ' Needs: CutString3(), Frequency(), RemoveHTMLTags()
    Rett = ""
    FoundR = 0
    For Each CRo in Split(Lookup_Table_HTML, " </tr >") ' Loop through rows
        CRo1 = " <tr " & CutString(CRo, " <tr ") ' Read from start of row until the end
        CRoCols = Frequency(CRo1, " </td >") ' How many columns in that row
        If CRoCols < Col_Index_Number Then Exit For ' We found columns less than the column we need to extract
        Colum1 = CutString3(CRo1, 1, " </td >")
        If Colum1 = CRo1 Then Exit For ' Could not find 1st col
        Colum2 = RemoveHTMLTags(Colum1)
        If SearchMethod = 1 And UCase(Lookup_Item) = UCase(Colum2) Then FoundR = 1
        If SearchMethod = 2 And VBInstr(Lookup_Item, Colum2) > 0 Then FoundR = 1
        If FoundR = 1 Then
            Rett = CutString3(CRo1, Col_Index_Number, " </td >")
            If Rett = CRo1 Then Exit For ' Could not find that column
            If ReturnHTMLCode = 2 Then Rett = RemoveHTMLTags(Rett)
            Exit For
        End If
    Next
    VLookup_HTML = Rett
End Function

Lookup_Item, Lookup_Table_HTML, Col_Index_Number, SearchMethod, ReturnHTMLCode

Views 155

Downloads 69

CodeID
DB ID