rob heibel
asked on
enable formatting rows through Thsworkbook VBA code
I originally wrote code in ThisWorkbook to allow the user to use the grouping function in a protected worksheet using the following code.
Private Sub Workbook_Open()
With Worksheets("Jobs By Pursuit Manager")
.Protect Password:="pursuits1", Userinterfaceonly:=True
.EnableOutlining = True
End With
End Sub
I then realized that even if I saved the file with autofilters and formatting rows allowed for the sheet, these attributes were removed upon opening the file.
I was able to add .EnablAutoFilter = True to the code, as shown below, but I cant seem to get the allowance of formatting rows to work. How do I add this to my code?
Private Sub Workbook_Open()
With Worksheets("Jobs By Pursuit Manager")
.Protect Password:="pursuits1", Userinterfaceonly:=True
.EnableOutlining = True
.EnableAutoFilter = True
End With
End Sub
Private Sub Workbook_Open()
With Worksheets("Jobs By Pursuit Manager")
.Protect Password:="pursuits1", Userinterfaceonly:=True
.EnableOutlining = True
End With
End Sub
I then realized that even if I saved the file with autofilters and formatting rows allowed for the sheet, these attributes were removed upon opening the file.
I was able to add .EnablAutoFilter = True to the code, as shown below, but I cant seem to get the allowance of formatting rows to work. How do I add this to my code?
Private Sub Workbook_Open()
With Worksheets("Jobs By Pursuit Manager")
.Protect Password:="pursuits1", Userinterfaceonly:=True
.EnableOutlining = True
.EnableAutoFilter = True
End With
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Rob, using ".AllowFormattingRows:=Tru e" creates a Compile error: "Expected: expression".
By using my original code, but then using Schum's technique of adding ", AllowFormattingRows" after userinterfaceonly:=True, it works perfectly. I ended up using the following:
Private Sub Workbook_Open()
With Worksheets("Jobs By Pursuit Manager")
.Protect Password:="pursuits1", Userinterfaceonly:=True, AllowFormattingRows:=True
.EnableOutlining = True
.EnableAutoFilter = True
End With
End Sub
By using my original code, but then using Schum's technique of adding ", AllowFormattingRows" after userinterfaceonly:=True, it works perfectly. I ended up using the following:
Private Sub Workbook_Open()
With Worksheets("Jobs By Pursuit Manager")
.Protect Password:="pursuits1", Userinterfaceonly:=True, AllowFormattingRows:=True
.EnableOutlining = True
.EnableAutoFilter = True
End With
End Sub
ASKER
By using my original code, but then using Schum's technique of adding ", AllowFormattingRows" after userinterfaceonly:=True, it works perfectly. I ended up using the following:
Private Sub Workbook_Open()
With Worksheets("Jobs By Pursuit Manager")
.Protect Password:="pursuits1", Userinterfaceonly:=True, AllowFormattingRows:=True
.EnableOutlining = True
.EnableAutoFilter = True
End With
End Sub
Private Sub Workbook_Open()
With Worksheets("Jobs By Pursuit Manager")
.Protect Password:="pursuits1", Userinterfaceonly:=True, AllowFormattingRows:=True
.EnableOutlining = True
.EnableAutoFilter = True
End With
End Sub
You're Welcome Rob! Glad it worked.
Open in new window