I have the below formula for calculating the root mean square error of the difference of two columns of data:

=SQRT(SUMPRODUCT((C2:C180-B2:B180)^2)/COUNT(B2:B180))

I would like to calculate this for filtered rows as well. I know SUBTOTAL needs to be used, and think the solution involves OFFSET, but haven't been able to come up with a formula that works. Any help would be much appreciated.