It might be more productive to determine the reason you're getting
the #Value! error in the first place...Sometimes it's unavoidable,
but usually trying to work around an error means a flaw in design.
One reason for the #Value! error would be if A2 or A4 contained text
rather than being blank or a number. IF A2 and A4 are directly
entered, the best answer is probably to train users not to make a
cell "blank" by entering a space, but that's often a losing battle.
You can instead use data validation to require that A2 and A4 be
either numeric or truly blank.
If A2 or A4 contain a formula that returns a null string, you can
either test for that directly:
=IF(AND(A2<>"",A4<>""),IF(ABS(A2-A4)<500,ABS(A2-A4),""),"")
or , depending on what are valid inputs, you might be able to use
the SUM function, which ignores text:
=IF(ABS(SUM(A2,-A4))<500,ABS(SUM(A2,-A4),"")
The other reason the formula might return an error is that one of
the inputs returns the #VALUE! error. In that case, fixing the input
is usually better than ignoring it.
One benefit of doing one of the above is that if A2 or A4 is
calculated and returns *any* error, not just the #VALUE! error, the
error will be passed through to alert the user that something is
amiss, rather than being ignored.