Using Excel 2000 (using 2k3 is not an option).
I have a sheet with a one header row and a bunch of data below it. I want to protect the sheet (actual data is not protected -- just want to prevent deletion/addition of columns).
I want the users to be able to:
1. Use autofilter
2. Sort based on certain columns by hitting a button. To do this, I added a button from the forms toolbar, stuck it in the header cell, and assigned it to a macro that unprotects the sheet, sorts, then protects the sheet.
Problem is, after protecting the sheet, I can sort it once. Then, I'm unable to click on the buttons to which I assigned the sort macros. Works fine if I remove the autofiltering, then protect it. Any ideas?
Here's the code in the sheet:
Sub Autpen()
With ActiveSheet
.Unprotect
.EnableAutoFilter = True
.Protect userInterfaceOnly:=True
End With
End Sub
Sub sortName()
ActiveSheet.Unprotect
Columns("A:O").Select
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("A2").Select
ActiveSheet.Protect userInterfaceOnly:=True
End Sub
Sub sortCategory()
ActiveSheet.Unprotect
Columns("A:O").Select
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("A2").Select
ActiveSheet.Protect userInterfaceOnly:=True
End Sub
Sub sortTYPE()
ActiveSheet.Unprotect
Columns("A:O").Select
Selection.Sort Key1:=Range("C2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("A2").Select
ActiveSheet.Protect userInterfaceOnly:=True
End Sub
I have a sheet with a one header row and a bunch of data below it. I want to protect the sheet (actual data is not protected -- just want to prevent deletion/addition of columns).
I want the users to be able to:
1. Use autofilter
2. Sort based on certain columns by hitting a button. To do this, I added a button from the forms toolbar, stuck it in the header cell, and assigned it to a macro that unprotects the sheet, sorts, then protects the sheet.
Problem is, after protecting the sheet, I can sort it once. Then, I'm unable to click on the buttons to which I assigned the sort macros. Works fine if I remove the autofiltering, then protect it. Any ideas?
Here's the code in the sheet:
Sub Autpen()
With ActiveSheet
.Unprotect
.EnableAutoFilter = True
.Protect userInterfaceOnly:=True
End With
End Sub
Sub sortName()
ActiveSheet.Unprotect
Columns("A:O").Select
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("A2").Select
ActiveSheet.Protect userInterfaceOnly:=True
End Sub
Sub sortCategory()
ActiveSheet.Unprotect
Columns("A:O").Select
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("A2").Select
ActiveSheet.Protect userInterfaceOnly:=True
End Sub
Sub sortTYPE()
ActiveSheet.Unprotect
Columns("A:O").Select
Selection.Sort Key1:=Range("C2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("A2").Select
ActiveSheet.Protect userInterfaceOnly:=True
End Sub