4
I have a spreadsheet in Excel 2013 that uses an INDEX
and MATCH
function to search by an interval time (in I4
) to pull values from the corresponding row where it is matched (in column A
). It works as expected on all rows except three – on those problem rows it actually returns the value from the cell above.
I am using the code:
=INDEX(B:B, (MATCH($I$4, A:A)))
The value I use to search for interval time is located in cell I4
(e.g., 10:00 AM), and the column it is matched to is A:A
. The values I am trying to return are located in B:B
.
The interval time column ranges from A2
-A37
(6:00 AM - 11:30 PM, in half-hour increments), and the values I want returned range from B2
-B37
.
ALL VALUES return correctly except when searching for values in A4
, A7
, and A10
(7:00 AM, 8:30 AM, and 10:00 AM, respectively), which display data from the cell above the desired value (i.e., when I4
= 7:00 AM (which equals A4
), the formula returns the value of B3
instead of B4
, I4
= 8:30 AM (A7
) → B6
instead of B7
, and I4
= 10:00 AM (A10
) → B9
instead of B10
).
When I try to use an exact match:
=INDEX(B:B, (MATCH($I$4, A:A, 0)))
it returns the value #N/A for the problem rows, and correct values for only some of the others.
Any insight into what is happening?
How are the values in col A stored (time values, text, etc.)? – fixer1234 – 2015-08-21T19:53:04.433
Both the column A values and the search value (I4) are formatted as time (ex. 8:00 AM) – JarrBett – 2015-08-21T19:55:35.703
1I wonder if the problem is floating point rounding error. – fixer1234 – 2015-08-21T20:01:45.267
the values I am trying to return (column B:B) are formatted as numbers with 2 decimal points. even when I use whole numbers with no decimal points it does the same thing, as well as using text - those 3 cells always return the value from the cell above – JarrBett – 2015-08-21T20:06:08.403
1>
Just on the off chance this is the issue... cells formatted as time may still have a date attached. You won't see it because it's hidden, but MATCH would be affected by that. Maybe temporarily switch the formatting to date & time to double check they're all on the same day? – Ask About Monica – 2015-08-21T20:17:03.930
I think it must be what fixer1234 said about the floating point rounding problem - what I did was format the interval time column to text (which of course changed all the values to decimal values), and just entered the interval times in again treating them as text only. Everything seems to search correctly now on all interval times. Thank you both for your input, that was driving me nuts! – JarrBett – 2015-08-21T20:30:24.820