I do not think you need the TableCount variable, and perhaps a few other things inside your original code. Hopefully, this will put you on your way...
Code:
> cat script.sh
#! /bin/bash
NumberOfTables="$#"
let TableCount=1
while [ ${NumberOfTables} -gt 0 ]
do
TableName='$'$TableCount
# db2 "runstats on table ${TableName} and indexes all"
# echo ${TableName}
echo $1
shift
let TableCount=TableCount+1
let NumberOfTables=NumberOfTables-1
done
exit 0