eksplosion310
New Member
I do not have much VBA knowledge but I put together a macro to hide rows that meet certain criteria (Module 2 in the sample provided). I am running into a problem where it takes a considerable long amount of time to run through about 1min and i know it could be simplified to run almost instant. No matter how many rows need to be hidden, meeting the criteria, the macro still takes the same amount of time. After many failed attempts I couldn't make it work. If anyone could shine some light on this and see how the code could be rewritten to work quicker.
Code:
Sub HideY()
Dim LastRow As Long, c As Range
Application.EnableEvents = False
ActiveSheet.DisplayPageBreaks = False
LastRow = Cells(Cells.Rows.Count, "Y").End(xlUp).Row
On Error Resume Next
For Each c In Range("Y10:Y1000")
If c.Value = 1 Then
c.EntireRow.Hidden = True
ElseIf c.Value = 2 Then
c.EntireRow.Hidden = False
End If
Next
On Error GoTo 0
Application.EnableEvents = True
ActiveSheet.DisplayPageBreaks = True
Set dbsTemp = Nothing
End Sub