try the following macro:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim ws As Worksheet, rCell As Range
For Each ws In Me
For Each rCell In ws.UsedRange
If rCell <> "" Then rCell.Locked = True
Next
Next
MsgBox "The data you entered has been locked successfully.", vbOKOnly
End Sub
This is a Workbook_BeforeSave event macro that will run every time the user saves the workbook (it runs just before the workbook is actually saved, hence the name). It must be written in "ThisWorkbook" object to function properly.
HTH!
Bookmarks