Mark Pearmain
New Member
- Joined
- Aug 23, 2022
- Messages
- 5
- Office Version
- 365
- Platform
- Windows
Hi!
I have used your code from another thread which works really well, however, I am running this on 250 rows and this takes quite some time to execute when hiding the rows, whereas the show part is instant. I tried running a macro to "TurnOffStuff" which turns off screen updating and calculations but this did not help. Please can you suggest any improvements to make this quicker?
many thanks for your help!
These are my helper macros:
I have used your code from another thread which works really well, however, I am running this on 250 rows and this takes quite some time to execute when hiding the rows, whereas the show part is instant. I tried running a macro to "TurnOffStuff" which turns off screen updating and calculations but this did not help. Please can you suggest any improvements to make this quicker?
many thanks for your help!
VBA Code:
Private Sub CommandButton1_Click()
If CommandButton1.Caption = "Hide" Then
Sub TurnOffStuff()
Dim c As Range
For Each c In Range("D8:D267")
If c.Value = "" Then c.EntireRow.Hidden = True
Sub TurnOnStuff()
Next c
CommandButton1.Caption = "Show"
Sub TurnOffStuff()
ElseIf CommandButton1.Caption = "Show" Then
Rows("8:267").EntireRow.Hidden = False
CommandButton1.Caption = "Hide"
Sub TurnOnStuff()
End If
End Sub
These are my helper macros:
VBA Code:
Sub TurnOffStuff()
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Application.EnableEvents = False
End Sub
VBA Code:
Sub TurnOnStuff()
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub