Skip to sidebar Skip to content
Ipercube Technical
Jack of all trades, master of none
Date: Time: - Stardate:
Welcome, Log in by clicking  Here!
SS64
MDN
Stack
Code
GitHub
Wiki
Convert
V Studio
  • Home
  • VB Functions
    • Access Functions
    • Assembly Info
    • Color/Image Functions
    • Data Table Functions
    • Email Functions
    • Active Directory Functions
    • LDAP Functions
    • Excel Functions
    • Logging Functions
    • Source Code Retrieval
    • String Functions
    • Sql Functions
    • Object Utilities Functions
    • System and Utilities
    • Utility Forms
  • VB Classes
    • Environment Variables Helper
  • ABAP
    • ABAP Reports
    • ABAP HTTP Functions
Ipercube Technical
  • Home
  • VB Functions
    • Access Functions
    • Assembly Info
    • Color/Image Functions
    • Data Table Functions
    • Email Functions
    • Active Directory Functions
    • LDAP Functions
    • Excel Functions
    • Logging Functions
    • Source Code Retrieval
    • String Functions
    • Sql Functions
    • Object Utilities Functions
    • System and Utilities
    • Utility Forms
  • VB Classes
    • Environment Variables Helper
  • ABAP
    • ABAP Reports
    • ABAP HTTP Functions

Table Manipulation – Lookup List Object Value

Searches for a specified value in the first column of an Excel.ListObject and returns the row index if found.

This function uses the Find method on the table’s data body range, looking only in the first column, with LookIn:=xlValues and LookAt:=xlWhole for exact match. If the value is not found or an error occurs, the function returns 0.

VB
    Public Function xlLookupListObjectValue(ListObject As Excel.ListObject, 
                                            LookupValue As String) As Integer

        If ListObject Is Nothing Then Return 0

        Try
            Dim FoundCell As Excel.Range = Nothing

            'Attempt to find value in Table's first Column
            Try : FoundCell = ListObject.DataBodyRange.Find(LookupValue, LookIn:=xlValues, LookAt:=xlWhole)
            Catch ex As Exception : End Try

            'Return Table Row number if value is found
            If Not FoundCell Is Nothing Then
                Return ListObject.ListRows(FoundCell.Row - ListObject.HeaderRowRange.Row).Index
            Else
                Return 0
            End If
        Catch ex As Exception
            Return 0
        End Try

    End Function

Posted by ipercube


© 2026 Ipercube Design