title: excel vba slowing excel down, causing 10 second egg timer delay when clicking anywhere on sheet
body: <p>I am using the following vba codes which im using to hide a set of rows and unhide rows depending on if a cell contains text or not, and they are causing my excel spreadsheet to be slow and unresponsive and causing the egg timer to show for about 10 seconds.</p>
  
  <p>If I take the code out It speeds things up so what can I do to my codes to get them to speed up and not take so long? perhaps there is a better way of structuring the code but im really new to vba so am not sure what I would need to do, would appreciate someone's help thanks.</p>
  
  <p>the reason I am using worksheet change and worksheet selection change is so that whether a user clicks on a cell or not the page still updates</p>
  
  <pre><code>Private Sub Worksheet_SelectionChange(ByVal Target As Range)
         If Range("K22").Value &lt;&gt; "" Then
      Application.ScreenUpdating = False
      Rows("25:38").EntireRow.Hidden = False
      Rows("40:48").EntireRow.Hidden = True
      ElseIf Range("K22").Value = "" Then
      Rows("25:38").EntireRow.Hidden = True
      Rows("40:48").EntireRow.Hidden = False
      End If
      Application.ScreenUpdating = True
  End Sub
  
  Private Sub Worksheet_Change(ByVal Target As Range)
         If Range("K22").Value &lt;&gt; "" Then
      Application.ScreenUpdating = False
      Rows("25:38").EntireRow.Hidden = False
      Rows("40:48").EntireRow.Hidden = True
      ElseIf Range("K22").Value = "" Then
      Rows("25:38").EntireRow.Hidden = True
      Rows("40:48").EntireRow.Hidden = False
      End If
      Application.ScreenUpdating = True
  End Sub
  </code></pre>