VBA to sum a dynamic range of only visible cells



would someone please help with a Macro code to sum only visible cells? My report is FILTERED and has two sections of numbers. The number of rows in each set changes all the time, but each set always has got a blank cell above and below. Numbers are in column O and I need the sum to appear in column P. thanks!











You want to use the SUBTOTAL function.


B1:B100 should be changed to the range that you want to sum.

As far as the SUM interval goes, I'm a bit confused. Are you performing two filters in separate tables of data?


Is it such that your filtered data will, every so often, have a blank value and it is at that, previously unkown row, that a SUM needs to be performed on all data above it and up to the next balnk or top of the page/data set?

Note: if you upload a sample file to your original question, it will be easier to help.



I uploaded the sample file. Each tab has got an example of the report
inna_01 Oct 26, '16 at 12:35 pm
Add to Discussion

Answer the Question

You must create an account to use the forum. Create an Account or Login