MrExcel Message Board


Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Mar 30th, 2004, 09:01 AM   #1
patrick_m84
 
Join Date: Mar 2004
Posts: 8
Default VLOOKUP CUSTOM FUNCTIONS

Hi guys

I'm kinda new to the concept of Functions, but have recently let my thoughts wonder, and wondered if you could clear something up for me.

A VLOOKUP, obviously is a function that will search for a particular item of data amongst a given range, and return the value at a particular column on that row. Currently, in the company i am in, we use a lot of VLOOKUPs in a Spreadsheet that is linked to a product file of about 40,000 products.

Now my question is this. As far as I can tell, VLOOKUP works on a linear search through data. This is understandable as the data it will be looking at is not necessarily ordered and therefore a binary chop is impossible.... unless the vlookup sorts, then searches, then unsorts.

Does anyone know how the VLOOKUP works? Because if it is a linear search, i may well attempt to write my own cutom function that will search using a chop and significantly higher response time.
patrick_m84 is offline   Reply With Quote
Old Mar 30th, 2004, 09:17 AM   #2
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 39,503
Default Re: VLOOKUP CUSTOM FUNCTIONS

I think you have an efficiency problem.

If the lookup table is not sortedin ascending order, you have to use...

VLOOKUP(LookupValue,LookupTable,ColIdx,0)

where the match-type (Help File: range_lookup) is 0 (or FALSE).

This invokes a linear search routine which is expensive.

If the lookup table is sorted in ascending order, you can have...

VLOOKUP(LookupValue,LookupTable,ColIdx,1)

where the match-type is 1 (TRUE).

This invokes a binary search routine which is fast.

If you could restrict lookup to a relevant subrange (subtable) of your lookup table, you could perform better.
Aladin Akyurek is offline   Reply With Quote
Old Mar 30th, 2004, 09:34 AM   #3
Ponsy Nob.
 
Join Date: Sep 2003
Posts: 994
Default Re: VLOOKUP CUSTOM FUNCTIONS

It is most unlikely that you will be able to create custom functions that are more efficient than Excels's built-in worksheet functions.

It is, however, often possible to create macros that manipulate the data before applying built-in functions in order to increase efficiency.
Ponsy Nob. is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT +1. The time now is 05:50 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
All contents Copyright 1998-2009 by MrExcel Consulting.