You are looking for a database/reporting tool functionality. It can be done
manually in Excel, but you'll have to be very careful with page breaks
Go into View>Page Break Preview. Starting at the top of the print range
scroll down to the first page break. Insert a row (or rows, if you prefer)
ABOVE THE page break. In the columns you want subtotaled use the
SUBTOTAL(9,range) function. The range to SUBTOTAL starts with the first row
of data and ends with the last row on this first page
Now repeat for each of the page breaks. However, the range to subtotal can
be EITHER the range of rows printing on the relevant page, or it can be all
the rows from the very top down to the last row on the relevant page.
For the grand total you'll again use the SUBTOTAL(9,...) function, but this
time use the entire column of data