Why does this work, and looks up values correctly
but once i change the order of values, it produces incorrect values?
If you read the notes on the LOOKUP function, it says:
The LOOKUP function will only work properly if data in search_range or search_result_array is sorted. Use VLOOKUP, HLOOKUP, or other related functions if data is not sorted.
Change your formula to use VLOOKUP as follows:
=VLOOKUP(D3, A1:B6, 2, FALSE)
Syntax:
VLOOKUP(search_key, range, index, [is_sorted])
search_key - The value to search for. For example, 42, "Cats", or I24.
range - The range to consider for the search. The first column in the range is searched for the key specified in search_key.
index - The column index of the value to be returned, where the first column in range is numbered 1.
is_sorted - [OPTIONAL - TRUE by default] - Indicates whether the column to be searched (the first column of the specified range) is sorted.