In any case, there is a fundamental issue with both approaches: since
hiding/unhiding rows doesn't trigger any event, such event will have to be
forced from time to time, or maybe you can leave with the formulae updating
their result in the next recalculation of the sheet.
Depending upon your needs, there is a Copy of visible only cells, click
Edit, Go To, select Visible Cells, then select the range and paste.
This new range can then be totalled.