Explain the use of VLOOKUP and HLOOKUP functions.

Both VLOOKUP and HLOOKUP are used to search for a value in a dataset and return a corresponding value from another column or row.


1. VLOOKUP (Vertical Lookup)
  • Searches for a value in the first column of a table and returns a value from a specified column in the same row.

  • Works when data is arranged in vertical columns.

  • Syntax:

    =VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])
    
  • Arguments:

    • lookup_value: The value to search for.
    • table_array: The range containing data.
    • col_index_num: The column number from which to return the result.
    • [range_lookup]: TRUE (approximate match) or FALSE (exact match). Default is TRUE.
  • Example:
    Suppose we have a table in A2:C5:

    ID Name Score
    101 John 85
    102 Alice 92
    103 Bob 78

    Formula:

    =VLOOKUP(102, A2:C5, 2, FALSE)
    

    Result: "Alice" (Finds 102 in column A and returns Name from column 2).


2. HLOOKUP (Horizontal Lookup)
  • Searches for a value in the first row of a table and returns a value from a specified row in the same column.

  • Works when data is arranged in horizontal rows.

  • Syntax:

    =HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])
    
  • Arguments:

    • lookup_value: The value to search for.
    • table_array: The range containing data.
    • row_index_num: The row number from which to return the result.
    • [range_lookup]: TRUE (approximate match) or FALSE (exact match).
  • Example:
    Suppose we have data in A1:E2:

    ID 101 102 103 104
    Score 85 92 78 88

    Formula:

    =HLOOKUP(103, A1:E2, 2, FALSE)
    

    Result: 78 (Finds 103 in row 1 and returns Score from row 2).


Key Differences Between VLOOKUP & HLOOKUP
Feature VLOOKUP HLOOKUP
Searches in First column First row
Works on Vertical data Horizontal data
Returns from A specified column A specified row
Example Use Find price of a product Find sales by month

Limitations of VLOOKUP & HLOOKUP
  • They only search from left to right (VLOOKUP) or top to bottom (HLOOKUP).
  • If the lookup column/row is changed, the formula can break.
  • Cannot look to the left in VLOOKUP (use INDEX-MATCH instead).