Hi all,
I've got a macro that runs through cells in a column and if the cell value is "HIDE" then it hides that entire row and if the cell is "Show" it ignores that row and continues until it finds another "HIDE" or to the first blank cell.
For someone reason it works in another file of mine but in the current file I'm using it causes excel to crash/not respond.
Any thoughts? It's an old macro I've had for a while so I'm sure it can use some updating.
Thanks,
I've got a macro that runs through cells in a column and if the cell value is "HIDE" then it hides that entire row and if the cell is "Show" it ignores that row and continues until it finds another "HIDE" or to the first blank cell.
For someone reason it works in another file of mine but in the current file I'm using it causes excel to crash/not respond.
Any thoughts? It's an old macro I've had for a while so I'm sure it can use some updating.
Code:
Sub Hide_Rows()
'
Dim strCurrentCell As String
Dim strCurrentSheet As String
strCurrentCell = ActiveCell.Address
strCurrentSheet = ActiveSheet.Name
Dim Calc_Setting As Long
Dim endrng As String
Dim Srtrng As String
Calc_Setting = Application.Calculation
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
On Error Resume Next
ActiveSheet.Unprotect Password:="password"
Cells.Select
ActiveSheet.Outline.ShowLevels RowLevels:=2
Selection.Rows.Ungroup
Range("AM:AN").Select
Selection.EntireColumn.Hidden = False
Range("AN1").Select
On Error Resume Next
Do
If ActiveCell = "HIDE" Then
Srtrng = ActiveCell.Address
Cells.Find(What:="Show", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
ActiveCell.Offset(-1, 0).Select
endrng = ActiveCell.Address
Range(Srtrng, endrng).Select
Selection.Rows.Group
Range(endrng).Select
ActiveCell.Offset(1, 0).Select
End If
If ActiveCell = "Show" Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until ActiveCell = ""
ActiveSheet.Outline.ShowLevels RowLevels:=1, ColumnLevels:=0
Range("AM:AN").Select
Selection.EntireColumn.Hidden = True
ActiveSheet.Protect Password:="password", DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingColumns:=True, AllowFormattingRows:=True, AllowFiltering:=True
Sheets(strCurrentSheet).Select
Range(strCurrentCell).Select
Range("B9").Select
Application.ScreenUpdating = True
Application.Calculation = Calc_Setting
End Sub