View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Aaron Aaron is offline
external usenet poster
 
Posts: 287
Default Slow Running Code to Hide Blank Rows

Hello All,

I am using the following code below to hide rows if cells in the range are
blank. It performs the function I desire better than any other solution I
tried. However, it runs slow (~10 seconds) and a cell in the sheet has to be
clicked to run the code if the blank cells in the range have changed and it
then runs everytime a cell in the sheet is clicked or edited.

Is there a way to speed it up greatly?
and/or
have it automatically update / update on change in the range only?
and/or
not run every time a cell in the sheet is clicked/edited?

I am a novice programmer.

Thank you for any help!

Option Compare Text

Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim cell As Range
Application.ScreenUpdating = False
With ActiveSheet.UsedRange

.Rows.Hidden = False
For Each cell In Range("A18:A98")
If cell.Value = "" Then _
cell.EntireRow.Hidden = True
Next cell
End With
End Sub