Way back in November, I received this email from Tom, a senior researcher at the Center for Learning Innovation in Australia.
I’ve been developing & have published spreadsheet applications for teachers for some time now. In particular, I have animations, adventure scenarios etc that can be used to create games for the classroom. I need to promote these so teachers eventually try these and use them. … Perhaps you could post some of these on your site.
What a noble cause, I thought. So I wrote back to him and invited him to share his files along with a guest article. Tom acted quick and emailed me his article and Excel workbooks by Thanksgiving day. I was too lazy and got lost in the flow of things. But now, I am very very glad to feature his work.
There are so many valuable tricks, ideas and powerful concepts buried in his workbook. I encourage everyone to play with his file (you need to enable macros) so that you can learn a thing or two. If you are a teacher, feel free to use the files to make your classroom teaching even more awesome.
What can you do with a spreadsheet? by Tom Benjamin

The spreadsheet was the original ‘must-have app’ that started the PC revolution because it allowed non-programmers to create loops. It is often overlooked in an era of countless cute free online calculators and interactivities. But few of the latter are easily deconstructed and customised to fit specific classroom needs, let alone being dressed in period costume to become a historical set or adventure cockpit for a an edu-game.
Now that Excel has incorporated graphic tools and form controls it is no longer ‘the boring old uncle’ of software. Its appearance can be as exciting as whatever graphic image you import into it. Its interactivity is as exciting as the context you give it in terms of setting the quest or adventure.
The accompanying spreadsheets cover a range of classroom applications. As demo’s they are intended to give you ideas rather than being a ‘finished product’ resource –ie- you need to look at the formulae to see how it works then change the content to fit your own purpose. These are available as free Creative Commons resources so you may deconstruct and re-purpose to your heart’s content. The main classes of spreadsheet covered here are as follows:
Graphics: Sheets 1-6
The clip art, vector drawing tools and general formatting provisions in Excel allow it to be used as a PowerPoint slide. Without even using formulae, graphic images can be used to hide clues, and elements can be moved around the screen, such as peeking under the ‘rocks’ in the dungeon example. This basic use fits in well with interactive white boards (IWBs). Vector drawing offers capabilities beyond the bitmap imagery in much IWB software. One effective technique is to use the huge library of special fonts such as scientific, i-Ching, Zodiacal, Roman Numeral, Arabic, WebDings and other symbols. Thus, a clue or answer can come up as an image rather than a number.

Although PowerPoint is better-equipped to display animated scenes, videos, sound, and animated .gifs, Excel can display changing frames merely by clicking between sheets manually, allowing complex visual animation. Software is readily-available to de-construct videos, animations and complex simulation modelling output into individual frames. Simple animation can be created by putting such a sequence of images on separate worksheets. The presenter can then scroll through these rapidly either via a form control button or merely hitting the next worksheet tab. This works especially well for full-screen graphics.
Charts: Sheets 7 -24
Charts can be dressed up with graphic borders, colours, and image elements so that they are scarcely recognisable as graphs. The ‘rocket cockpit’ example shows how steering wheels, instrument control panels, and simulated instruments of all types can be created merely by surrounding them with graphic borders. In primary school these might merely be used as visual display items, for instance the flickering torches and spider web in the Dungeon example. Or these could be linked to a formula so that they only flickered or appeared when a wrong answer was given. Setting the mood for such games falls outside the spreadsheet realm but the graphic images used in an adventure game can be set as backgrounds or images in a spreadsheet. Thus, pictures of the various decks of the ship in a pirate adventure could become background images. The player would then work from sheet to sheet inputting words or numbers which would make something happen in the scene, such as the sail rising or the cannon shooting, all of which could take place within a chart by converting its bar graph or pie graph elements to picture backgrounds.
Slider formula controls: Sheets 7-24
In addition to text and numerical input, Excel allows sliders and spinners to control cells. These cells can then trigger events in the sheet. Especially useful for vivid graphical display are protractors made from pie charts as attached. Contour maps are versatile as they can create pictures using colours and image-fills. The attached examples show clues being generated by moving a slider.
More complex animations can be created by linking the picture-filled elements of a chart with ‘0-1’ ‘on-off-switch’ formulae. Examples are shown in the attachments. Again, these are limited only by their quality and imaginative use. Full-blown videos or animations created in other software can be exported to individual frames. Moving a slider can then call up the individual frames. A ‘virtual puppet’ and ‘news desk’ are shown as examples. It would be more commonly applied to illustrating a concept difficult to show with live-action such as the satellite fly-by. The latter could be linked to formulae showing the distance from Earth, velocity etc. These values can be taken from more sophisticated software rather than trying to calculate them with Excel formulae.

Again, the imagination of the presenter is key in that a quick visual simulation may not need to be exact to illustrate a classroom concept. It need only be as good as what might have formerly been portrayed by a sweep of the chalk on a blackboard. The big advantage of the spreadsheet over the chalkboard may be less its imagery than the fact that it can be saved, improved and re-used rather than wiped after the session.
Artificial intelligence and interactive: Sheets 24-27
Human judgment of complex rating decisions can be simulated merely using in-built mathematical formulae without resorting to logical formulae, much less programming. Pearson correlations are a built-in function and other matching formulae are easily programmed. The attached example uses the Spearman Rank-Order formula to score the similarity of a launch sequence against an ‘ideal’ sequence-order. Research has consistently shown that such seemingly ‘simple’ formulae can reliably outperform even highly-trained professionals if given a good set of answer criteria.
The value of such artificial intelligence models in the classroom is that they can interact with the learner and that they can be seen to be fair and unbiased provided the criteria for judgment are made explicit to the learner. The Bidding Game and Balloon Launch Sequence examples demonstrate such uses. They are easy to create as they use built-in functions so are limited only by their imaginative use.

If we want our programme to really seem lifelike we can add language interaction. This is important if learners are supposed to be typing in queries like “how tall is…?” or “who is…?” but decide to play around and input irrelevant and irreverent comments. Excel has a range of logical ‘lookup’ expressions that can be combined with formulae to create responses.
The number of cells was a limitation in earlier spreadsheets but the 65536 rows now available allows for at least some limited language response. The random number function refreshes with each entry so that a more life-like interaction can be achieved by linking a rand() function to a cell such that the value changes to an integer drawing randomly from a set of response words/phrases. The final worksheet example ‘the crashing bore’ shows what can be done using commands to parse the input string, a look-up to identify key words, another lookup to match responses to those words, and a random function to prevent the same answers reappearing. More complex interaction could be achieved by constraining user input to specific questions like “how much”, “where is” etc, using weightings, and pattern-correlating against the input string. Graphics can make the ‘chatterbot’ answer-machine interaction seem more life-like or appropriate (like HAL9000 the computer from 2001: A Space Odyssey).
Download the Excel Files
Please click here to download the Excel Workbook for Teachers [this file is 9MB, so give it sometime to download]
Also, Tom made a simple Excel skills test. Click here to download and test your Excel skills.
Thank you Tom
A big thanks to Tom for sharing this valuable work with all of us. I have already learned some good tricks from his workbook (creating image slide-show thru charts+scroll-bar, running formulas on click of button, using contour charts etc.). I am sure you too will find some interesting areas of application or learn some valuable things by examining his workbook.
If you like this workbook, please say thanks to Tom.
Also, if you are teacher, please share your experience of using Excel in teaching effectively.














54 Responses to “6 Tips for Writing Better VLOOKUPs”
Hi, I am loving the VLOOKUP series this week. 🙂
Could you please expand a little on why you don't recommend using 1 or 0 in place of true or false? I am in the habit of doing this.
"You can even omit the last argument if it is 0"
Excel's default for the last argument is TRUE. Because of this, it's dangerous to omit the last arguement. I would use either FALSE or 0. Never omit if you want an exact match.
Nice series, Chandoo!
.
Your readers may be interested to know that the quickest formula method to do lookups in Excel is an array-entered INDEX.
.
This is one of the many topics covered in the Excel Hero Academy:
Excel Hero Academy
.
Regards,
Daniel Ferry
Excel Hero Academy
Dear Daniel,
I had used index-match with absolute reference for the ranges but when I am resorting the table the formula is not recalulating the lookup value combination.
Regards,
Anish Menacherry
@Anish
Can you post the question at the Chandoo.org Forums
http://chandoo.org/forum/
Please include a sample file so we can review the issue
1. Never use VLOOKUP/HLOOKUP - Always use Match /Index
2. Sort your data before performing a Loookup
3. Use 1/-1 option Match as it is at least 10 times faster than the 0 option- But modified to perform an exact match rather than an approximate match as described below
a) A Column containing a Match Fucntion to Find the Position with the 1/-1 option
b) A Status column containing a Index to check the status (present/not present)
c) Multiple array entered Index colums to pick
In tip number 5 you state, "you can even omit the last argument if it is 0" which is not correct. If you omit the last argument, Range_Lookup, is TRUE, as Mike Alexander points out.
Excellent series - Need some help from the expert. how easy it is to add/expand a named range in a lookup formula?
@Mike & Gregory: I am sorry for the confusion. The formula =VLOOKUP(value, range, column #) assumes last argument as TRUE.
Where as the formula =VLOOKUP(value, range, column #, ) assumes last argument is blank or empty which internally gets treated as 0.
And that is what I mean by you can even omit last argument. I state that "Remember, you must place a comma (,) after the column number if you are planning to use this." otherwise, this will not work.
@Andrew: I suggest not using 0 or 1 as they are more cryptic and lead to confusion when your spreadsheet gets to someone else's hands.
@Daniel: Thanks for that.
@Sam: Good tips. I would just add that using VLOOKUP / HLOOKUP is ok as long as they solve the problem you have and do not take too much time. The performance improvements you get with array entered index or other techniques are minimal when dealing with small and moderately sized data sets.
@Sundeep
Very easy
Have a read of: http://chandoo.org/wp/2009/10/15/dynamic-chart-data-series/
Particularly Point 3. Create a new named range and type OFFSET formula
@Hui - Thanks.
If I have a large workbook with many Vlookups and if I change the range to named range...is there an easy way to change all the formulas? It is more of wishful thinking than a question 🙂
@Sundeep... You can use Apply names from formulas ribbon to apply names to a selected range. This technique works when the ranges are mapped to static references. Dynamic refs. thru OFFSET are bit more tricky.
You can use the find / replace to automatically replace all $A$1:$C$1000 with dynamic range lstData. See this: http://chandoo.org/wp/2009/02/17/spreadsheet-formulas-edit/
@Sundeep
On the Formulas Tab, Click on the Drop Down on the Define Name button and select Apply Names
Select one or all Named Ranges and apply
Excel will go through your worksheet/s and change the Ranges for Named Ranges.
i cannot believe i missed the new to 2007 formula "IFERROR". your mention of this will help reduce the number of characters in many formulars i use (with "ISERROR") by at least 40% along with commensurate reductions in spreadsheet size and calculation speed... not to mention future reduction in typing and debugging time in formulas. thank you. and thank excel.
Newbie here.
I am not able to understand the Tip#1. Use of "val", "tbl". I tried and it kept on giving error.
Chandoo's Tip#1: =VLOOKUP(valSalesPerson,tblData,3,FALSE)
Does it need column headings? And how do you l lookup the value I am looking.
Thanks in advance.
[...] 6 VLOOKUP Tips [...]
[...] VLOOKUP, INDEX, and MATCH: Useful for looking up any text values [...]
I need some help with creating a formula. I have a list of names on tab 1. (About 20) On tab 2 I have a list of names and there total sales (About 3,500) I created a name range for both the first list of names on tab 1 (Producer) and a name range for the second list on tab 2 (Agent_List) The sales on tab 2 for each producer is in the 7th colume.
I need the formula to identify name of Producer (Tab1) from the Agent_List and then choose the total sales for that producer.
This is the formula I put together and I only get #REF!
VLOOKUP(PRODUCER,AGENT_LIST,7,FALSE)
@JimH
I assume you are adding a column next to the Agent_List on Tab 2 and looking up values from the Agent_List and retrieving values from the Producer list
.
So the format for your equation will be:
=VLOOKUP(A2,Producer,7,FALSE)
or
=VLOOKUP(Agent_List,Producer,7,FALSE)
.
Note that the named range Producer must be at least 7 columns wide, not just Column A or you will get the #REF! error also
Hi
Can anyone please help or this totally impossible in excel? I am trying to do a vlookup with a range of cells that contains "comments" in them and unsuccessful.
Thank you
@Lala
You cannot search within comments unless you use VBA
My tips are:
Pay attention to data types - no fly if mixing text and numbers. I run into this problem a lot with files downloaded from access that have a tendency to mix data types on me when it hits excel.
Pay attention to $ - If pulling from the same workbook, $ won't auto fill on your range and you will potentially miss hits.
Yeah, the data type mixing has bitten several folks I work with in the rear.
EG: I work at a company where marketing source codes are 10-alphanumeric. But, some codes are like "12345" while others are "123abc". When access or sql dumps to excel, the numerical ones convert to numbers while the text ones stay text.
So, what I do is create a reference column next to them in which I do a =TRIM([column]). Trim not only removes front/back spaces, it converts a value to text data type. This is useful, b/c sometimes sql db admins will store data with a fixed string length (eg: a column may get stored as char(50), which means it will have 50 chars no matter if it has to add extra spaces at the end to pad it out.) When you dump this to excel, the extra spaces remain at the end. So, the Trim command not only converts numbers to text, it removes padded spaces at the end. Very useful when working with sql dumps.
I have two sheets, in first sheet i have given a criteria of month (like jan, feb), then on another sheet i have month wise sheet like
jan feb mar
a 2 5 8
b 5 9 8
c 9 12 89
now i need in first sheet if i give criteria jan then answer is 2+5+9, or if i give feb then answer is 5+9+12 and like that, how to get that??
I am pretty well versed in VLOOKUP but I have a challenge I can't figure out. When I complete the VLOOKUP in one cell, it works fine. When I drag the formula down (using $ where necessary) the value from the first LOOKUP populates in the new cell. If I double click on the cell and hit 'enter' then the correct value is pulled in from the vlookup. Any suggestions why the formula isn't executing correctly until I hit enter?
@Nicole
It sounds like Calculation is set to Manual
Goto the Data Tab Calculation and set it to Automatic
Absolutely FANTASTIC!! Thank you so much. Slight variation on my version of Excel. I had to go to Formulas Tab then to Calculation sub-tab, Calculation Options, change setting to Automatic. Thank you thank you thank you. Saved me hours of more frustration!
[...] than maybe sorted, which it usually is anyway).Use COUNTIF or MATCH to speed up calculationAs many others have pointed out, VLOOKUP returns #N/A if the lookup value is not found. Instead of using a [...]
I have more than 2 columns in a table I'm so confused cuz the results i get is #N/A =(
I have a 2-sheet database. Sheet 2 has a list of Accronyms in column A and their description in column B. On sheet 1, column A is where you input your Acronym. In column B, the formula takes Acronym from column A, looks it up on sheet 2, and displays it on column B.
After some research, I found how to make custom text if there is not a match on the Acromyn. The question i have is, is that when there is no text in comumn A, sheet 1, column B, sheet 1 displays my custom text "ABBREVIATION NOT FOUND". I'm trying to write a forumla that leaves column B blank unitl there is an input in column A.
This is my current forulma:
=IF(ISNA(VLOOKUP(A4,Description!A:B,2,FALSE)),"ABBREVIATION NOT FOUND",(VLOOKUP(A4,Description!A:B,2,FALSE)))
Any help out there?
Thanks,
Jerome
Hi Jerome... Thanks for your question. Try this formula instead:
=IF(A4<>"", IFERROR(VLOOKUP(A4,Description!A:B,2,FALSE),”ABBREVIATION NOT FOUND”), "")
Works in XL 2007 or above. For older versions use this:
=IF(A4<>"", IF(ISNA(VLOOKUP(A4,Description!A:B,2,FALSE)),”ABBREVIATION NOT FOUND”,(VLOOKUP(A4,Description!A:B,2,FALSE))), "")
Btw, to learn more about IFERROR see this: http://chandoo.org/wp/2011/03/11/iferror-formula/
I have 2 worksheet, the first one is like this:
A B C D
1 DOG 1 BROWN
1 DOG 2 WHITE
2 CAT 1 SMALL
2 CAT 2 MEDIUM
2 CAT 3 BIG
THE SECOND WORKSHEET IS LIKE THIS:
A B C D
ENTER# fORMULA 1 WITH VLOOK ENTER # FORMULA 2
(RETURN ANIMAL) RETURN TYPE
FOR EXAMPLE i NEED WORKS LIKE THIS:
2 CAT 2 MEDIUM
FIRST FORMULA IS EASY NOT PROBLEM. bUT FOR THE SECOND i DO NOT FIND HOW TO DO IT. PLEASE HELP.
This would be how I would handle your second formula, in your first worksheet, I would insert a column between C & D. In that column I would have a formula to concatenate the values in column A & C (example =concatenate(a2,c2)) which would result in:
A B C D E
1 DOG 1 11 BROWN
1 DOG 2 12 WHITE
2 CAT 1 21 SMALL
2 CAT 2 22 MEDIUM
2 CAT 3 23 BIG
Then in the second worksheet formula 2 would be:
=vlookup(concatenate($a2,$c2),AnimalType columns D&E,2,false)
Great Stuff Chandoo
In your 6th post you say use SUMIF instead of VLOOKUP as it runs faster.
What if you have a spread sheet with repeated data and you only want to pull one value back?
would it be best to use a simple VLOOKUP
or something like: IF(COUNTIF < 2, SUMIF, VLOOKUP)
I have set COUNTIF < 2 (not just = 1) to take advantage of the fact that if COUNTIF = 0 you won’t get an error
Now if only you could use the column header name instead of the column index number in the VLOOKUP function.
Scenario: I have a list/table in one spreadsheet that I use to lookup values in other spreadsheets. If I insert columns in my list/table, I have to go into the other spreadsheet(s) and increment the VLOOKUP formulas' column index number to capture the right column of values.
Example: if I inserted a column in Table1, my formula:
=VLOOKUP(A1,Table1,2,FALSE) would have to change to:
=VLOOKUP(A1,Table1,3,FALSE),
it would be so much better if you could code something like:
=VLOOKUP(A1,Table1,Table1[price],FALSE)
If my lookup result is numeric data I could use sumif as suggested and use the list/table references; is there a similar function I can use for alphanumeric data lookups that uses list/table references?
[…] Read more – 6 VLOOKUP tips […]
tip:
you can use dynamic column reference for your look up if you want to pull multiple column values from another sheet with the same row reference without having to rewrite the the formula, e.g.
range a1:d1 = "header", 2 , 3, 4
b2 = vlookup($a2, LookUpRange, b$2, 0)
c2 = vlookup($a2, LookUpRange, c$2, 0)
b3 = vlookup($a3, LookUpRange, b$2, 0)
the above will bring back the value two columns away from LookUpRange in b2, 3 for c2 and 4 for d2 for the same reference, a2. By freezing just the column for your lookup reference value and just the rows for your column reference, you can drag your forums both down and right while keeping all reference both constant and dynamic... as oxymoronic as that sounds.
my TIP, building on what Andy says above re using a dynamic refrence: if you use the column functon in the header row - should someone add extra columns to the source sheet your lookup will adapt and still return the right result.
With the below formula I am getting "too many arguments for this function. any help?
=IFERROR(VLOOKUP(RIGHT(M3,7),notes!A:A,1,FALSE),"Failure to process correctly",IFERROR(VLOOKUP(RIGHT(n,2),notes!A:A,1,FALSE),"Failure to process correctly"))
Chaz - IFERROR only requires 2 arguments, you have entered 3 (the vlookup, the error message, the 2nd IFERROR).
Change your formula to the following:
=IF(isERROR(VLOOKUP(RIGHT(M3,7),notes!A:A,1,FALSE)),”Failure to process correctly”,IFERROR(VLOOKUP(RIGHT(n,2),notes!A:A,1,FALSE),”Failure to process correctly”))
Ian
Hmm, I'm not sure my formula will return the required output.
This tests if there is an error in the 1st vlookup, then checks the 2nd, and only returns the error message if both vlookups are errors. Is that what you wanted to do?
=IF(isERROR(VLOOKUP(RIGHT(M3,7),notes!A:A,1,FALSE)),IFERROR(VLOOKUP(RIGHT(n,2),notes!A:A,1,FALSE),”Failure to process correctly”),VLOOKUP(RIGHT(M3,7),notes!A:A,1,FALSE))
I am trying to use a vlookup with a named range for the lookup array. This works fine. However now I would like to replace this named range with a cell reference (which obviously contains the name of the named range) but get a N/A error message. Is this really not possible?
vlookup ( A1, named range, 2, 0 ) . This works
vlookup ( A1, F1, 2, 0 ) . Where cell F1 contains the the text with named range. This does not work.
Any tips or thoughts would be appreciated. Thank you in advance
@Erik
Use: vlookup ( A1, Indirect(F1), 2, 0 )
Works like a charm. Thank you!
Some opinions on the pros and cons of using named ranges on http://www.excelvlookuphelp.com along with a few other hot tips
Hello,
Chandoo,
Can u explain me how to use vlookup formula in 2 sheets in one excel workbook.
Hi am Using Index match function to overcome the limitation of Vlookup. But I am failed to get the same result as i get in Vlookup. in vlookup as we can expand the Columns of Vlookup in one single shot. Like Vlookup($A4,A1:G9,3,0) but same Result i Not get in Index match Function. Please help
@Satish
I will suggest that your list is unsorted and it is possible that VLookup is returning a wrong answer
Can you post a question at the Chandoo.org Forums
http://chandoo.org/forum/
Post a sample file and someone will review
I want to upload a Sample file Contain my Question. but i can't see and upload file button on the page. Please Tell how to upload the File
@Satish
You can't upload a file here
But you can on the Forums
Goto:
http://chandoo.org/forum/
Select a Forum
Start a New Thread
Upload a File, is at the Bottom next to the Post Button
Refer: http://chandoo.org/forum/threads/posting-a-sample-workbook.451/#post-73705
thanxx... Soon i will Upload It.
Dear Excel super-users,
Sourcing data from different sheets.
I'd like to specify in the vlookup formula which sheet to source data from.
This source sheet will change depending of the name of the person selected in a specific cell C1 on the sheet where the vlookup formula is being run from.
I'd be grateful for any tips to achieve this.
Regards,
Sean
dear sir /madam
please proved me lookup formula
and exp--------- insert picture formula attched excel sheet
Us the Column formula in place of the 3rd argument will save you time when you want to bring in all data columns!