leebrockney
New Member
- Joined
- Feb 19, 2008
- Messages
- 18
hello all!! I am trying to build a statement creation tool within Excel. the statement has a few different sections that could range anywhere from a few rows to a couple hundred rows. I am using the below code to review the statement and to hide and unhide any rows that are either unused or were hidden but now have data which means they need unhidden. the problem I am having is that this code takes A LONG TIME to run. probably around 2 minutes each time I kick the code off. While this isn't a long time in the bigger scheme of things, the admin who will be using this has to create dozen and dozens of these reports and 2 minutes each is a big deal when duplicated across many statements.
I am just hoping that maybe there is a more efficient code that wouldnt take so long to run. thanks for any feedback you might have!
Sub Button1_Click()
Dim stmntRange As Range
Application.ScreenUpdating = False
For Each stmntRange In Range("E11:E658")
If (stmntRange.Value = "") Or (stmntRange.Value = "0") Then
stmntRange.EntireRow.Hidden = True
Else
stmntRange.EntireRow.Hidden = False
End If
Next stmntRange
Application.ScreenUpdating = True
End Sub
I am just hoping that maybe there is a more efficient code that wouldnt take so long to run. thanks for any feedback you might have!
Sub Button1_Click()
Dim stmntRange As Range
Application.ScreenUpdating = False
For Each stmntRange In Range("E11:E658")
If (stmntRange.Value = "") Or (stmntRange.Value = "0") Then
stmntRange.EntireRow.Hidden = True
Else
stmntRange.EntireRow.Hidden = False
End If
Next stmntRange
Application.ScreenUpdating = True
End Sub