T
Tami
I have the following code to hide and display rows as needed. For example if
cell k1=000 display all rows. if k1=846, then any row with 846 in column in
I will be displayed.
It works well but its really slow.
Does anyone see what may be slowing it down?
Thanks in advance for any and all advice.
t.
Dim class As Variant, i As Long
If Intersect(Target, Range("k1")) Is Nothing Then Exit Sub
Me.unprotect Password:="paspas"
Application.ScreenUpdating = False
Application.EnableEvents = False
UsedRange.Rows.Hidden = False
If Cells(1, 11) = "000" Then
Columns("B").Select
If Columns.Hidden = False Then
ActiveSheet.Outline.ShowLevels RowLevels:=1
ActiveWindow.FreezePanes = False
Rows("2:3").Hidden = True
Range("k8").Select
ActiveWindow.FreezePanes = True
Else
ActiveSheet.Outline.ShowLevels RowLevels:=1
ActiveWindow.FreezePanes = False
Rows("2:3").Hidden = True
Range("p8").Select
ActiveWindow.FreezePanes = True
End If
Else
class = Cells(1, 11).Value
For i = 8 To Cells(400, 9).End(xlUp).Row
If Cells(i, 9) <> class Then Rows(i).Hidden = True
Next i
Columns("B").Select
If Columns.Hidden = False Then
ActiveSheet.Outline.ShowLevels RowLevels:=1
ActiveWindow.FreezePanes = False
Range("k6").Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
ActiveCell.Offset(-1, 0).Select
ActiveWindow.FreezePanes = True
Else
ActiveSheet.Outline.ShowLevels RowLevels:=1
ActiveWindow.FreezePanes = False
ActiveCell.Select
Rows("2:3").Hidden = True
Range("p6").Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
ActiveCell.Offset(-1, 0).Select
ActiveWindow.FreezePanes = True
End If
End If
Application.ScreenUpdating = True
Application.EnableEvents = True
Me.Protect Password:="paspas", AllowInsertingRows:=False,
AllowDeletingRows:=False
End Sub
cell k1=000 display all rows. if k1=846, then any row with 846 in column in
I will be displayed.
It works well but its really slow.
Does anyone see what may be slowing it down?
Thanks in advance for any and all advice.
t.
Dim class As Variant, i As Long
If Intersect(Target, Range("k1")) Is Nothing Then Exit Sub
Me.unprotect Password:="paspas"
Application.ScreenUpdating = False
Application.EnableEvents = False
UsedRange.Rows.Hidden = False
If Cells(1, 11) = "000" Then
Columns("B").Select
If Columns.Hidden = False Then
ActiveSheet.Outline.ShowLevels RowLevels:=1
ActiveWindow.FreezePanes = False
Rows("2:3").Hidden = True
Range("k8").Select
ActiveWindow.FreezePanes = True
Else
ActiveSheet.Outline.ShowLevels RowLevels:=1
ActiveWindow.FreezePanes = False
Rows("2:3").Hidden = True
Range("p8").Select
ActiveWindow.FreezePanes = True
End If
Else
class = Cells(1, 11).Value
For i = 8 To Cells(400, 9).End(xlUp).Row
If Cells(i, 9) <> class Then Rows(i).Hidden = True
Next i
Columns("B").Select
If Columns.Hidden = False Then
ActiveSheet.Outline.ShowLevels RowLevels:=1
ActiveWindow.FreezePanes = False
Range("k6").Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
ActiveCell.Offset(-1, 0).Select
ActiveWindow.FreezePanes = True
Else
ActiveSheet.Outline.ShowLevels RowLevels:=1
ActiveWindow.FreezePanes = False
ActiveCell.Select
Rows("2:3").Hidden = True
Range("p6").Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
ActiveCell.Offset(-1, 0).Select
ActiveWindow.FreezePanes = True
End If
End If
Application.ScreenUpdating = True
Application.EnableEvents = True
Me.Protect Password:="paspas", AllowInsertingRows:=False,
AllowDeletingRows:=False
End Sub