Let's break down HLOOKUP in detail.
What is HLOOKUP?
HLOOKUP (Horizontal Lookup) is an Excel function that searches for a specific value in the first row of a table and returns a value in the same column from a row you specify. Think of it like looking up a word in a dictionary index (the first row) and then reading the definition on the line below (the specified row).
Formula:
=HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])
Arguments Explained:
-
lookup_value
: The value you're searching for in the first row of thetable_array
. This is like the word you're looking up in the dictionary index. In your example, this isC13
(the District name). -
table_array
: The range of cells that contains your lookup table. This is like the entire dictionary index and definitions. In your example, this isD4:AD7
. It must include the first row where you're searching for thelookup_value
. -
row_index_num
: The row number within thetable_array
from which you want to retrieve the corresponding value. The first row of thetable_array
is row 1, the second is row 2, and so on. In your example, this is2
because the Taluk is in the second row of the rangeD4:AD7
. -
[range_lookup]
(Optional): This argument specifies whether you want an exact match or an approximate match.FALSE
or0
: (Recommended) Finds an exact match for thelookup_value
. If it doesn't find an exact match, it returns an error (#N/A
). This is what you're using in your example.TRUE
or1
or omitted: Finds an approximate match. The first row of thetable_array
must be sorted in ascending order for this to work correctly. HLOOKUP will find the largest value in the first row that is less than or equal to thelookup_value
.
Example Breakdown (Based on your text):
You have a table (your "BOOK") in the range D4:AD7
. The first row (D4:AD4
) contains District names. The second row (D5:AD5
) contains Taluk names.
You want to find the Taluk for a specific District. The District name you're looking for is in cell C13
.
The formula you use is:
=HLOOKUP(C13,D4:AD7,2,FALSE)
C13
: The District name (yourlookup_value
).D4:AD7
: The table containing District and Taluk data (yourtable_array
).2
: The second row of the table contains the Taluk names (yourrow_index_num
).FALSE
: You want an exact match for the District name.
How it Works:
- HLOOKUP looks in the first row of
D4:AD7
(the District names) for the value inC13
. - If it finds an exact match, it goes down to the second row (because
row_index_num
is 2) in the same column where it found the match. - It returns the value in that cell (the Taluk name).
Example 2 (Copying the Formula):
When you copy the formula =HLOOKUP(I12:N12,D4:AD7,2,FALSE)
and drag it across to N13
, Excel automatically adjusts the lookup_value
. So, in cell J13
, the formula will become something like =HLOOKUP(J12,D4:AD7,2,FALSE)
, and so on. This is a very efficient way to look up multiple Taluks. However, the original formula HLOOKUP(I12:N12,D4:AD7,2,FALSE)
is incorrect. The first argument should be a single cell, not a range. It should be HLOOKUP(I12,D4:AD7,2,FALSE)
.
Key Rules (Recap):
- Lookup value in the first row: The value you're searching for must be in the first row of the
table_array
. - Sorted for approximate match: If you use
TRUE
or omitrange_lookup
, the first row must be sorted in ascending order. - Exact or approximate match: Use
FALSE
for exact matches (recommended) andTRUE
for approximate matches. - Row index number: Specify the correct row number to retrieve the desired value.
HLOOKUP is very useful for looking up data in tables where the lookup values are arranged horizontally in the first row. Just remember these rules, and you'll be able to use it effectively.