In the control options tab there's is a setting (Melee Can Ignore Selected Target) that will let melee attacks ignore your selected target if it's out of range and instead choose the nearest target to off on instead. It seems to work fine with click/charge or maintain melee attacks but energy builders will still use your selected target instead of the nearest.
0