It sounds like you're making an RTS, so let's say you need to have a building that automatically attacks the nearest enemy within 100 metres.
A naive (and inefficient) approach would be to calculate the distance to every enemy unit, find the minimum, and ensure that it's within 100 m. Then you have your target. However, this means that for every N buildings and M enemies, you have to do N*M distance tests.
One optimization you can make is to use a distance squared check to eliminate the relatively expensive square root operation. So instead of checking the distance against 100 m, you check distance^2 against 10,000 m^2. This will save a bit of time but you're still working with an O(N*M) complexity.
Here is where spatial partitioning comes in. Now, you can do a broad test to first find which partitions may potentially intersect with the building's range, and narrow down the list of candidates for enemies to attack significantly. Applying both of these optimizations should give you a significant average-case cost reduction.
This is the exact same thing that you would do in a generic collision detection algorithm - narrowing down the list of candidates through a gauntlet of cheap (and usually parallel) early-out tests. Indeed, you could implement the building's broad phase query as a collision test against the circle/sphere that bounds its range, which might be useful if you're using a 3rd-party collision/physics library.