Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

VBA to sum a dynamic range of only visible cells

0

Hello,

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!

 1.00

 5.00 

 6.00    

             SUM

 3.00  

 9.00    

             SUM

Answer
Discuss

Answers

0

You want to use the SUBTOTAL function.

=SUBTOTAL(9,B1:B100)

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?

OR

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.

Discuss

Discussion

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