How to Lock the data in a cell in excel using vba

后端 未结 5 779
鱼传尺愫
鱼传尺愫 2020-11-27 19:34

I want to stop others from editing the cell contents in my excel sheet using VBA. Is it possible to do this?

5条回答
  •  野性不改
    2020-11-27 19:45

    Sub LockCells()
    
    Range("A1:A1").Select
    
    Selection.Locked = True
    
    Selection.FormulaHidden = False
    
    ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= False, AllowFormattingCells:=True, AllowFormattingColumns:=True, AllowFormattingRows:=True, AllowInsertingColumns:=True, AllowInsertingRows:=True, AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True, AllowDeletingRows:=True, AllowSorting:=True, AllowFiltering:=True, AllowUsingPivotTables:=True
    
    End Sub
    

提交回复
热议问题