我准备了以下宏来取消保护工作表,对数据进行排序,然后再次保护工作表。
它工作得很好,除了在我原来的保护设置中我允许用户插入行,但是当宏重新保护工作表时,它会阻止用户执行此操作。
有人可以给我一些积分来获得允许插入行的保护吗?
Sub CustSort1()
ActiveSheet.Unprotect "password"
Range("a14").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Sort Key1:=Range("a14"), Order1:=xlAscending, Key2:=Range( _
"k14"), Order2:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, _
DataOption3:=xlSortNormal
Range("a14").Select
ActiveSheet.Protect "password"
End Sub
感谢您的帮助。
最佳答案
在ActiveSheet.Protect
语句之后可以设置一堆标志,包括是否允许插入行。一个例子:
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True , AllowInsertingRows:=True
关于vba - 用于保护工作表并允许插入行的宏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26365720/