Hey guys, I'm just wondering how I can edit this VBA code to enable outlining so I can use grouping whilst the spreadsheet is still protected.
The code is run off a button within the spreadsheet.
I also noticed that when this runs on my main sheet it is quite quick but any other sheets in the workbook I run it on the spreadsheet freezes for 30 seconds before running the action.
The code is run off a button within the spreadsheet.
VBA Code:
Sub Button2_Click()
Dim pswStr As String
pswStr = "Password1234!"
On Error Resume Next
Application.ScreenUpdating = False
ActiveSheet.Unprotect Password:=pswStr
ActiveSheet.Range("A4").Select
'A4 is tabel header'
Range("Table1[[#Headers],[Total]]").Select
Selection.End(xlDown).Select
Selection.ListObject.ListRows.Add AlwaysInsert:=False
ActiveSheet.Protect Password:=pswStr, DrawingObjects:=True, Contents:=True, Scenarios:=True, _
UserInterfaceOnly:=True, AllowFormattingCells:=False, AllowFormattingColumns:=False, _
AllowFormattingRows:=False, AllowInsertingColumns:=False, AllowInsertingRows:=False, _
AllowInsertingHyperlinks:=False, AllowDeletingColumns:=False, AllowDeletingRows:=False, _
AllowSorting:=False, AllowFiltering:=True, AllowUsingPivotTables:=False
End Sub