You could use Select to get rid of the Nulls
In[7]:= Select[{2, Null, 3, 4, Null}, # =!= Null &]
Out[7]= {2, 3, 4}
or use Select instead of If to get the results you want, which is probably the better approach.
In[8]:= Select[Range[5], 2 <= # <= 4 &]
Out[8]= {2, 3, 4}