Shell script with awk command for counting in a file

Hi,
I hope you can help me with the awk command in shell scripting.
I want to do the following, but it doesn't work.

for i in $REF1 $REF2 $REF3; do
awk '{if($n>=0 && $n<=50000){count+=1}} END{print count}' ${DIR}${i} >${DIR}${i}_count.txt
done

REF1 to REF3 are only variables for .txt files.DIR is the working directory.
Is $n correct for the last column in the files? And I want to have an output file, where the variable count is print.
Can someone help me?

It should be $NF instead of $n

Also awk is capable of reading multiple input files. No need to use a for loop.