Finding the nearest feature to reference point in a target layer

Discussion created by filipeestacio on Oct 28, 2013
Latest reply on Oct 28, 2013 by Neil
Hi all,

I've been searching the forums for the past few days and trying out different solutions but somehow can't work this one out. I'm in the middle of coding up a macro that automates a number of functions we have and need to find a way of doing the following:

I have a point feature selected and want to find the nearest feature of a different layer.

Essentially it's writing the code of a private function such as "GetNearestPoint(RefFeature as IFeature, TargetLayer as ILayer, pMap as IMap).

However the TargetLayer that applies in my case has literally millions of entries and there is no way I can write code that goes through all of them. Also I'm running ArcMap through Citrix so performance is an issue. Any suggestions?