Assume you want to count all rows that are not empty -- the CountA function -- and assume you want to count the rows in column A. The formula would be SUBTOTAL(103,A:A)-1. The syntax is as follows: subtotal(function_number, reference), where function_number is 1 of many possible options as illustrated below. I included the "-1" to remove the count for the column heading row.
(includes hidden values)
(ignores hidden values)
Note: I used Excel 2003 for this example.