LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 210
Default modifiying a custom lookup function


A former collegue created a custom function which would work like vlookup but
find the specified instance of the data being searched instead of being
limited to just the first instance.
Example: VWLookup(PolicyDataSource,"Anderson",5,3)

This would find the 3rd instance of Anderson in the named range
"PolicyDataSource" and pull in the data from the 5th column.

Is there a way to customize this function to allow for an additional
criteria to search on? For example, if column 3 is policy_status and I want
to filter for 'Active'.

Any help is appreciated!


Public Function VWLookup(Table_Array As Object, _
Lookup_Value As Variant, Col_Index_Num As Integer, _
Match_Number As Integer) As Variant

Dim i, j As Integer

On Error GoTo ErrorCatch

For i = 1 To Match_Number
j = Application.Match(Lookup_Value,
Table_Array.Resize(Table_Array.Rows.Count, 1), 0)

If i = Match_Number Then
VWLookup = Application.VLookup(Lookup_Value, Table_Array,
Col_Index_Num, 0)
Exit Function
End If

Set Table_Array = Table_Array.Offset(j,
0).Resize(Table_Array.Rows.Count - j)

Next i

ErrorCatch:
VWLookup = "N/A"
End Function

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a custom function to interpret another custom engine func Ryan Excel Programming 0 March 3rd 08 07:18 PM
Custom Lookup Function Greg[_23_] Excel Programming 5 December 17th 05 10:05 AM
VBA Custom function for lookup Sami82 Excel Worksheet Functions 9 September 12th 05 03:20 PM
[Help Needed] Custom Lookup Function [email protected] Excel Programming 1 August 11th 05 01:16 AM
Modifiying a text number ( 12345 ) to have exactly 6 digit with a 0 in front simon.guertin Excel Programming 4 August 28th 03 06:55 PM


All times are GMT +1. The time now is 12:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"