Myriad_Rocker
Board Regular
- Joined
- Dec 1, 2004
- Messages
- 67
I have a sub that goes through my sheet and hides certain rows. It takes FOREVER to run. I'm looking to speed it up. It's the actual hiding of the row that takes some time.
I thought about creating a new named range and adding to the named range in the loop and then issuing one hide command at the end. But I figured I'd get some other eyes on it so I could come up with the best solution.
I thought about creating a new named range and adding to the named range in the loop and then issuing one hide command at the end. But I figured I'd get some other eyes on it so I could come up with the best solution.
Code:
Sub HideRows()
Dim RowNum As Long
Dim RowCnt As Long
'Making sure we're on the right sheet
Sheets("Weekly Sales Report").Select
'The row we're starting on
RowNum = 15
RowCnt = 15
'Get the number of rows to do
Do Until IsEmpty(Range("B" & RowNum).Value)
RowNum = RowNum + 1
Loop
Do Until Range("B" & RowCnt).Row = RowNum
If Left(Range("B" & RowCnt).Value, 1) = " " Then
Range("B" & RowCnt).EntireRow.Hidden = True
Else
Range("B" & RowCnt).EntireRow.Hidden = False
End If
RowCnt = RowCnt + 1
Loop
Range("AC1").Value = 1
End Sub