Hide Zero Value Rows Faster

Will85

Active Member
Joined
Apr 26, 2012
Messages
254
Office Version
  1. 365
Platform
  1. Windows
I have 40 tabs in my workbook.
Each tab is an Income Statement
Each tab has about 300 rows of accounts with columns six wide of annual financial data (2020,2019,2018,2017,2016,2015)
Column A has a filter on it
Each row in column A has a formula that sums 2020 through 2015 for that row, if the sum doesn't equal zero (meaning there is financial data for this account) then the result is 1, if the sum does equal zero then the result is 0.

My macro goes through each tab, and filters based on Column A. The goal is to only display accounts that have financial data, and hide the rows that don't.

The financial data is using sumifs pulling from a table that itself is updating from an outside SQL database.

It takes several minutes for my macro to go through each tab and hide the Zero rows, is there any way to improve the speed?

This is my macro.

Sub Hide_Rows()
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual

Dim ary As Variant
Dim sht As Variant

With Sheets("Macro")
ary = .Range("A1", .Range("A" & Rows.Count).End(xlUp)).Value
End With
For Each sht In ary
With Sheets(CStr(sht))
.Unprotect "password"
.Range("A1:A700").AutoFilter 1, "1"
.Protect "password"
.EnableSelection = xlUnlockedCells
End With
Next sht
Sheets("Control").Select

Application.ScreenUpdating = True
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic

End Sub
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
I think I need to get rid of the filter and maybe do an if statement inside of my loop???
If a cell in column A .value=0 then .rows hidden = true

Something like this, but I am not sure how to get this to work.
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,320
Members
452,635
Latest member
laura12345

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