Presentation is loading. Please wait.

Presentation is loading. Please wait.

VLookup and HLookup in Microsoft Excel

Similar presentations


Presentation on theme: "VLookup and HLookup in Microsoft Excel"— Presentation transcript:

1 VLookup and HLookup in Microsoft Excel

2 VLookup Searches for a value in the first column of a table array and returns a value in the same row from another column in the table array. Collingsworth 1 Comanche Dallas 16 Denton 6 El Paso 4 Ellis 2 Fannin Fort Bend Galveston

3 HLookup Searches for a value in the top row of a table or an array of values, and then returns a value in the same column from a row you specify in the table or array. El Paso Ellis Fannin Fort Bend Galveston 4 2 1

4 Syntax VLOOKUP (lookup_value, table_array, col_index_num,
range_lookup) What you’re looking for Where you’re going to look What you want to know Is ‘close’ good enough? HLookup has the same syntax, with “row_index_num” instead of “col_index_num”. We’ll talk about VLookup today.

5 lookup_value The value to search for in the first column of the table array. If lookup_value is smaller than the smallest value in the first column of the table array, VLookup returns the #N/A error value.

6 table_array Data in columns.
If the table is not sorted in ascending order on the first column, the function can give unpredictable results. Use ‘absolute’ references. (Put a $ before the letters and numbers in the references, i.e. $A$2:$B$255) Do not include column headers

7 col_index_num The column number in the table array from which the matching value must be returned. A col_index_num of 1 returns the value in the first column in the table array; col_index_num of 2 returns the value in the second column, and so on.

8 range_lookup A logical (True/False) value that specifies whether you want VLookup to find an approximate match or an exact match. Defaults to “True”. You will almost always want it to be “False”.

9 VLookup were looking for
What would happen if VLookup were looking for Dallam County in this table and returning the second column? Collingsworth 1 Comanche Dallas 16 Denton 6 El Paso 4 Ellis 2 Fannin Fort Bend Galveston With range_lookup left as “True”, the value for Comanche County will be returned. With range_lookup set to “False” an error message will show that Dallam County was not found. We can deal with error messages!!

10 Why would we submit ourselves to such a complicated function?
SO WHAT ?!?!?! Why would we submit ourselves to such a complicated function?

11 Incidence Rate by County
Combine data tables Case Count by County Population by County Incidence Rate by County

12 Example Two worksheets:
“Case Count” has a list of case counts by county. “County Population” has a list of all counties with their populations.

13 County =VLOOKUP(A2,'Case Count'!$A$1:$B$58,2,FALSE)
This formula will return an error for any county that has no cases. What we really want is 0 This is where it gets complicated…

14 Handling Errors This is where I lose people…
If the original formula gives an error, we want a zero. Otherwise we want the result of the original formula. The Excel function IfError() will let us choose between the value of a function (vlookup) or another value if the function returns an error.

15 =IfError([original formula], 0)

16 =IFERROR(VLOOKUP(A2,'Case Count'!$A$1:$B$58,2,FALSE),0)

17 Where might we use True for the range_lookup parameter?
To group numeric values into ranges.

18 VLookup were looking for
What would happen if VLookup were looking for 24 in this table and returning the second column? 0 - 4 5 5 - 9 10 18 25 35 45 55 65 65+ With range_lookup set to “False” an error message will show that 24 was not found. We don’t want an error message, or a default value. We want an ANSWER!

19 VLookup were looking for
What would happen if VLookup were looking for 24 in this table and returning the second column? 0 - 4 5 5 - 9 10 18 25 35 45 55 65 65+ With range_lookup set to “True”, Vlookup will start at the top of the table, work its way down to the last value in column 1 that is earlier in the sort than the lookup_value. The table MUST be sorted by the first column!! You will get wrong answers, and it may not be obvious that they are wrong. In this version of Vlookup, there are no error messages for missing values.

20 Investigation ID2 Age Reported Birth Time Event Date Age Age Group CAS TX01 49 7/8/1966 11/21/2015 CAS TX01 53 7/18/1961 2/14/2015 CAS TX01 59 7/22/1955 3/5/2015 CAS TX01 8 6/18/2014 3/3/2015 0 - 4 CAS TX01 47 5/19/1967 CAS TX01 1 8/14/2013


Download ppt "VLookup and HLookup in Microsoft Excel"

Similar presentations


Ads by Google