Yay, since I was the one who suggested the automatization of oil ships
I must answer.
There is no function to get the closest unit of a type.
You'll have to write one.
Well, I think it's solvable in GUI but it would be much easier in JASS.
If you know JASS then there is a GetClosestUnit() function allready in the JASS section made by DiscipleOfLife.
If you don't you should learn it, I like your maps. If you don't want well.. It should be a loop in a loop. The outer loop would change the distance you check around the oil tanker unit and pick the pick all units in the distance then save it to a variable. The inner loop would take the group from the outer loop and it would check if the first unit in the group is a Shipyard or not. If it's not a shipyard then remove the first unit in the group from the group. If it's a shipyard then save this unit in a variable then exit from the loops.
There you go, your closest unit.
But to tell you the truth, it's not the optimal solution for your problem. I would rather save the location of each players' shipyards to a variable and just do some very simple math to figure out which one is the closest. That would require less processing from the computer, less coding and thinking from you.