GalvinGreene
New Member
- Joined
- Feb 15, 2022
- Messages
- 2
- Office Version
- 365
- 2021
- 2019
- Platform
- Windows
So I have written some code that is meant to hide and unhide rows directly beneath the cell I am changing from OPEN to CLOSE and back again. The only thing is it is painfully slow doing that. Which I wouldn't mind if it wasn't also painfully slow entering in data in the sheet...
Is there anyway to speed this up?
Is there anyway to speed this up?
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim iRow As Integer
Dim j As Integer
Dim k As Integer
Dim iCol As Integer
iCol = ActiveCell.Column
iRow = ActiveCell.Row
If iCol = 15 Then
Application.ScreenUpdating = False
Application.DisplayStatusBar = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
ActiveSheet.DisplayPageBreaks = False
j = iRow + 1
k = iRow + 3
If iCol = 15 Then
If iRow >= 12 Then
If iRow < Range("W4").Value Then
If Round(iRow / 4, 0) = iRow / 4 Then
If ActiveCell.Value = "CLOSE" Then
Range(j & ":" & k).EntireRow.Hidden = True
Else
Range(j & ":" & k).EntireRow.Hidden = False
End If
Else
End If
Else
End If
Else
End If
Else
End If
End If
Application.ScreenUpdating = True
Application.DisplayStatusBar = True
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
End Sub