I'm trying to break down a chunk formula in smaller parts.

I must find the value of time closest to time values in an array and the answer must be chosen from a different row. So here goes

Male 10
Age Cat GOLD SILVER BRONZE
< 20 00:34:00 00:36:30 00:39:00
20-34 00:34:00 00:36:30 00:39:00
35-39 00:35:30 00:38:00 00:40:00
40-49 00:36:30 00:39:00 00:41:00
50-59 00:38:00 00:41:30 00:44:00
60+ 00:40:00 00:44:30 00:48:30

Sheet 1: I have data = distance, gender, age cat and time
Sheet 2: I have above

I must find/use on Sheet 1 distance, gender, age cat and time end, look up the time on sheet 2 [the data above] and my result must be Gold, Silver of Bronze.

Example: Distance = 10; Gender = Male; Age cat = 40-49; time = 0:38:38 from Sheet 1. My result must be SILVER as 0:38:38 is slower than 0:36:30 but faster than 0:39:00

This must be done for male and female, but I think if I got the concept, I can apply it everywhere.
A mouthful, but if this possible in a formula