After recorded the macro with the existing data, when I tried to add new rows and blank, it doesn't collapse those newly rows that blank. Do you know why? Macro code below:
================================================================
Sub Button1()
Application.ScreenUpdating = False
ActiveSheet.Unprotect
Selection.AutoFilter
ActiveSheet.Range("$B$3:$H$146").AutoFilter Field:=2, Criteria1:="="
ActiveSheet.Range("$B$3:$H$146").AutoFilter Field:=3, Criteria1:="="
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowInsertingColumns:=True, AllowInsertingRows:=True, _
AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True, _
AllowDeletingRows:=True, AllowSorting:=True, AllowFiltering:=True, _
AllowUsingPivotTables:=True
Application.ScreenUpdating = True
End Sub
Sub Button2()
Application.ScreenUpdating = False
ActiveSheet.Unprotect
Selection.AutoFilter
ActiveSheet.Range("$B$3:$H$146").AutoFilter Field:=3, Criteria1:="="
ActiveSheet.Protect
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowInsertingColumns:=True, AllowInsertingRows:=True, _
AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True, _
AllowDeletingRows:=True, AllowSorting:=True, AllowFiltering:=True, _
AllowUsingPivotTables:=True
Application.ScreenUpdating = True
End Sub
Bookmarks