Combination VBA / Formulation trick to sum Visible cells onl

Chris The Rock

Active Member
Joined
Feb 24, 2002
Messages
287
Setup:
I've got 31 days worth of data in rows 4 through 33, and a Totals Row in row 34. Trows that correspond to days that have not occurred yet are hidden. Each morning, I unhide a new row and data goes into each of the columns. As a result of this, the Totals row changes.

Question:
What I want to do is this: I would like the Totals line to perform functions ONLY on the visible rows. For example, if Rows 6 - 33 are hidden, I'd like the TOTALS row (row 34) to perform its functions (SUM, AVERAGE, etc) on ONLY ROWS 4 and 5. Likewise, if all the rows between 4 and 33 are visible, it should perform functions on ALL the rows.

How can I accomplish this? My first thought is to establish some sort of TRUE / FALSE variable for each row that tells whether the row is hidden or not. Then, I could use SUMIF-style formulas. But, alas, I don't know how to do this, or even if it will work or not.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
I'm assuming that you have a column that has the date in it as well. If that's the case, I'd suggest using the Autofilter feature on the date column (Data|Filter|Autofilter) combined with the "SUBTOTAL" function.

The criteria for Autofilter would be "is less than" the first date you want to be invisible.

If you then look in the help file you will see that SUBTOTAL can do AVERAGE, SUM, etc on data that is hidden only by using Autofilter.

HTH
 
Upvote 0

Forum statistics

Threads
1,214,588
Messages
6,120,409
Members
448,959
Latest member
camelliaCase

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top