You need to have a temp variable to store your result and another to hold what you are searching for.
You then would loop through your grid checking each item against your search value and your temp var to see if the current item is closer to your search value than what is in temp var. If it is closer then replace the value in temp var with the current value from the grid and continue moving through the grid until you get to the end.

If the grid is sorted on that column then you could stop sooner. Once you get close then if you see the next value is farther away that the one you have then you would know that you have the one that would be closest. If it is not sorted then there is no way to tell until you test them all.

The exception would be if one were an exact match you would accept that one and exit the loop since it can't possibly be any closer.