Here's some info on the SUBTOTAL() function.

http://www.excelfunctions.net/Excel-...-Function.html