I have a Macro that is working to Show/Hide specific rows or columns based on a "Y"/"N" placed in a specific cell. Everything is working however, it is slowing down the entire sheet when I move from cell to cell there is a slight delay. Is there a better way to write this code so that it does not create this delay throughout the whole worksheet?
Code:
''Show/Hide Unit Labor Line Item Pricing for BOM With Out Unit Pricing
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = False
Application.EnableEvents = Fales
If Range("J3").Value = "N" Then
Rows("9").EntireRow.Hidden = True
ElseIf Range("J3").Value = "Y" Then
Rows("9").EntireRow.Hidden = False
End If
If Range("J5").Value = "N" Then
Rows("11").EntireRow.Hidden = True
ElseIf Range("J5").Value = "Y" Then
Rows("11").EntireRow.Hidden = False
End If
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
Code:
''Show/Hide Unit Labor Line Item Pricing for BOM With Out Unit Pricing
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = False
Application.EnableEvents = Fales
If Range("J3").Value = "N" Then
Rows("9").EntireRow.Hidden = True
ElseIf Range("J3").Value = "Y" Then
Rows("9").EntireRow.Hidden = False
End If
If Range("J5").Value = "N" Then
Rows("11").EntireRow.Hidden = True
ElseIf Range("J5").Value = "Y" Then
Rows("11").EntireRow.Hidden = False
End If
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub