Vous êtes sur la page 1sur 3

Excel Function Dictionary 1998 - 2000 Peter Noneley A 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 B C D E F G H I

HLOOKUP Page 1 of 3 J

HLOOKUP
Jan 10 20 30 40 50 Feb 80 90 100 110 120 Mar 97 69 45 51 77 Feb 4 100 =HLOOKUP(F10,D3:F10,F11,FALSE)
row 1 row 2 row 3 row 4 row 5 row 6 The row numbers are not needed. they are part of the illustration.

Type a month to look for : Which row needs to be picked out : The result is :

What Does It Do ? This function scans across the column headings at the top of a table to find a specified item. When the item is found, it then scans down the column to pick a cell entry. Syntax =HLOOKUP(ItemToFind,RangeToLookIn,RowToPickFrom,SortedOrUnsorted) The ItemToFind is a single item specified by the user. The RangeToLookIn is the range of data with the column headings at the top. The RowToPickFrom is how far down the column the function should look to pick from. The Sorted/Unsorted is whether the column headings are sorted. TRUE for yes, FALSE for no. Formatting No special formatting is needed. Example 1 This table is used to find a value based on a specified month and name. The =HLOOKUP() is used to scan across to find the month. The problem arises when we need to scan down to find the row adjacent to the name. To solve the problem the =MATCH() function is used. The =MATCH() looks through the list of names to find the name we require. It then calculates the position of the name in the list. Unfortunately, because the list of names is not as deep as the lookup range, the =MATCH() number is 1 less than we require, so and extra 1 is added to compensate. The =HLOOKUP() now uses this =MATCH() number to look down the month column and picks out the correct cell entry. The =HLOOKUP() uses FALSE at the end of the function to indicate to Excel that the column headings are not sorted, even though to us the order of Jan,Feb,Mar is correct. If they were sorted alphabetically they would have read as Feb,Jan,Mar. Jan 10 20 30 Feb 80 90 100 Mar 97 69 45

Bob Eric Alan

Excel Function Dictionary 1998 - 2000 Peter Noneley A 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 B C Carol David D 40 50 E 110 120 F 51 77 feb alan G H I

HLOOKUP Page 2 of 3 J

Type a month to look for : Type a name to look for :

The result is : 100 =HLOOKUP(F54,D47:F54,MATCH(F55,C48:C52,0)+1,FALSE) Example 2 This example shows how the =HLOOKUP() is used to pick the cost of a spare part for different makes of cars. The =HLOOKUP() scans the column headings for the make of car specified in column B. When the make is found, the =HLOOKUP() then looks down the column to the row specified by the =MATCH() function, which scans the list of spares for the item specified in column C. The function uses the absolute ranges indicated by the dollar symbol $. This ensures that when the formula is copied to more cells, the ranges for =HLOOKUP() and =MATCH() do not change. Maker Vauxhall VW Ford VW Ford Ford Vauxhall Ford Spare Ignition GearBox Engine Steering Ignition CYHead GearBox Engine Cost 50 Vauxhall Ford VW 600 GearBox 500 450 600 1,200 Engine 1000 1200 800 275 Steering 250 350 275 70 Ignition 50 70 45 290 CYHead 300 290 310 500 1,200 =HLOOKUP(B79,G72:I77,MATCH(C79,F73:F77,0)+1,FALSE)

Example 3 In the following example a builders merchant is offering discount on large orders. The Unit Cost Table holds the cost of 1 unit of Brick, Wood and Glass. The Discount Table holds the various discounts for different quantities of each product. The Orders Table is used to enter the orders and calculate the Total. All the calculations take place in the Orders Table. The name of the Item is typed in column C. The Unit Cost of the item is then looked up in the Unit Cost Table. The FALSE option has been used at the end of the function to indicate that the product names across the top of the Unit Cost Table are not sorted. Using the FALSE option forces the function to search for an exact match. If a match is not found, the function will produce an error. =HLOOKUP(C127,E111:G112,2,FALSE) The discount is then looked up in the Discount Table If the Quantity Ordered matches a value at the top of the Discount Table the =HLOOKUP will look down the column to find the correct discount.

Excel Function Dictionary 1998 - 2000 Peter Noneley A 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131

HLOOKUP Page 3 of 3

B C D E F G H I J The TRUE option has been used at the end of the function to indicate that the values across the top of the Discount Table are sorted. Using TRUE will allow the function to make an approximate match. If the Quantity Ordered does not match a value at the top of the Discount Table, the next lowest value is used. Trying to match an order of 125 will drop down to 100, and the discount from the 100 column is used. =HLOOKUP(D127,E115:G118,MATCH(C127,D116:D118,0)+1,TRUE) Unit Cost Table Wood Glass 1 3

Brick 2

Brick Wood Glass

Discount Table 1 100 0% 6% 0% 3% 0% 12% Orders Table Unit Cost Discount 2 6% 1 3% 3 12% 2 6% 1 0% 3 15%

300 8% 5% 15%

Item Brick Wood Glass Brick Wood Glass Unit Cost Discount

Units 100 200 150 225 50 500

Total 188 194 396 423 50 1,275

=HLOOKUP(C127,E111:G112,2,FALSE) =HLOOKUP(D127,E115:G118,MATCH(C127,D116:D118,0)+1,TRUE)

Vous aimerez peut-être aussi