Target Range Options

I use a macro while tanking however the main problem I run into is that "/targetenemy [noharm][dead] " does not have a range limit and if I’m not very careful I can easily pull other mobs. The main culprate is Moonfire but I also run into issues when a DPS is using focus target. Is there a solution to this such as a range limit, say 5 yards or perhaps a way to only target an enemy that I’m currently attacking? Ideally I would like a range limit but if not is there an effective way to bypass “/targetenemy [noharm][dead]” without interrupting my macro? Below is my current macro;

Sequences[‘Bear’] = {
StepFunction = GSStaticPriority,
PreMacro=[[
/targetenemy [noharm][dead]
/cast [@player, nostance:1] Bear Form
]],

“/castsequence reset=combat Mangle, Thrash, Moonfire, Swipe”,
“/castsequence reset=combat Thrash, Moonfire, Swipe, Mangle”,
“/castsequence reset=combat Moonfire, Swipe, Mangle, Thrash”,
“/castsequence reset=combat Swipe, Mangle, Thrash, Moonfire”,
“/castsequence reset=combat Mangle, Thrash, Moonfire”,
“/cast Mangle”,
“/cast Swipe”,
“/cast Mangle”,

PostMacro=[[
/startattack
/script UIErrorsFrame:Hide();
/console Sound_EnableSFX 1
]],
}

Thanks in advance!

In the General options there is a setting for Target Hop Protection - This requires that you have a current target for the macro to work. It then effectively disables your /targetenemy line. There is no “range Check” that you can do in a macro to filter out targets that are X far away. Blizzard took all the range and distance checks out with 7.1