I have a spreadsheet that needs to toggle show/hide rows that are dependent on Column G values.
I have two Buttons:
- [Show All] - This will execute a sub to show all rows.
- [Hide FALSE] - This will execute a sub to Hide any rows where its value in Column G = FALSE
The problem is that the Sub only needs to run through 250 rows, but it take about 5 minutes to complete the sub. I assure you it has nothing to do with my PC specs.
Excel VBA Code:
'This sub takes about 5 minutes to complete (WHY?)
Private Sub btnHideFalse_Click()
Application.ScreenUpdating = False
Dim i As Integer
Dim wsSelect As Worksheet
Set wsSelect = ThisWorkbook.ActiveSheet
For i = 2 To 250
'Cells(i,7) point to the current row's column G value
wsSelect.Rows(i).EntireRow.Hidden = (wsSelect.Cells(i, 7).Value = False)
Next i
Set wsSelect = Nothing
Application.ScreenUpdating = True
End Sub
'This sub works great
Private Sub btnShowAll_Click()
ThisWorkbook.ActiveSheet.Rows("1:250").EntireRow.Hidden = False
End Sub