John
John

Reputation: 961

Excel VLOOKUP function source code

Is there anyway that I can find the source code of the function VLOOKUP in excel(VBA) so I can modify it? Google does not give me any help. Thanks!

Upvotes: 2

Views: 5554

Answers (3)

Homero Esmeraldo
Homero Esmeraldo

Reputation: 2563

Based on Vahid's answer, which didn't work for me, I did the following code that did work:

Function CUSTOMVLOOKUP(lookup_value As String, table_array As Range, col_index_num As Integer)
    Dim i As Long
    For i = 1 To table_array.Rows.Count
        If lookup_value = table_array.Cells(i, 1) Then
            CUSTOMVLOOKUP = table_array.Cells(i, col_index_num)
            Exit For
        End If
    Next i
End Function

Upvotes: 0

Vahid Dastitash
Vahid Dastitash

Reputation: 1

This is a simple implementation of Vlookup:

        Public Function VLOOKUP1(ByVal lookup_value As String, ByVal table_array As Range, ByVal col_index_num As Integer) As String
        Dim i As Long

        For i = 1 To table_array.Rows.Count
            If lookup_value = table_array.Cells(table_array.Row + i - 1, 1) Then
                VLOOKUP1 = table_array.Cells(table_array.Row + i - 1, col_index_num)
                Exit For
            End If
        Next i

        End Function

Upvotes: -2

barrowc
barrowc

Reputation: 10679

Excel/VBA is not open source so the source code of a particular function is not available.

You could write your own UDF (user-defined function) in VBA to produce your modified version.

There's also a more flexible (non-VBA) version of VLOOKUP/HLOOKUP at http://www.cpearson.com/Excel/FlexLookup.aspx

Upvotes: 7

Related Questions