Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Anyone who'd encountered problems when they encapsulate VLookup or
HLookup? I'm trying to write a generalized lookup function which I can control the direction of lookup through an argument but when I step the code through, it stops execution at the line of .VLookup/ .HLookup. It does not halt the program flow and execute all cells that uses this formula with #VALUE! result. Public Function MyGeneralLookUp(Direction As Long, Key As Range, TableName As Range, StartPoint As Long, Match As Boolean) As String MyGeneralLookUp = "" Application.EnableEvents = False ' Some key to search with If (Not (CStr(Key.Value) = "")) Then ' Initialize an offset table so that data can be retrieved from the correct position Call CreateOffsetTable ' Calculate offset distance off StartPoint Offset = SeekOffset(OffsetTag) With Application.WorksheetFunction ' Enforce looking up exact key Match = (Not Match) ' Lookup value depending on direction Select Case Direction Case HDir FetchedResult = .VLookup(Key, TableName, Offset, Match) Case VDir FetchedResult = .HLookup(Key, TableName, Offset, Match) End Select ' No error from lookup & result is either a text or number If ((Not .IsError(FetchedResult)) And _ (((.IsText(FetchedResult)) Or (.IsNumber(FetchedResult)))) _ ) Then MyGeneralLookUp = FetchedResult End If End With End If Application.EnableEvents = True End Function Would appreciate any suggestions or pointers! Cheers! _______ cLiffordiL |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
am having lookup problems, please help | Excel Discussion (Misc queries) | |||
LOOKUP problems | Excel Worksheet Functions | |||
Problems with LOOKUP | Excel Worksheet Functions | |||
v-lookup problems | Excel Worksheet Functions | |||
Lookup problems | Excel Worksheet Functions |