Hide Zero Value Rows Faster

Will85

Board Regular
Joined
Apr 26, 2012
Messages
240
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

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
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,214,837
Messages
6,121,883
Members
449,057
Latest member
Moo4247

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