You can automatically password protect an Excel worksheet and lock cells after data entry using a macro. Here are the steps to create such a macro:
Open the worksheet in which you want to password protect and lock cells after data entry.
Press Alt + F11 to open the Visual Basic Editor.
In the Visual Basic Editor, click on "Insert" and select "Module."
Copy and paste the following code into the module:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell As Range
Dim password As String
password = "yourpassword"
For Each cell In Range("A1:D10") 'Change the range to the cells you want to lock
If Not Intersect(cell, Target) Is Nothing Then
cell.Locked = True
End If
Next cell
ActiveSheet.Protect Password:=password
End Sub
Replace "yourpassword" with the password you want to use.
Change the range "A1:D10" to the range of cells you want to lock after data entry. You can also modify the code to lock individual cells instead of a range.
Save the macro and close the Visual Basic Editor.
Go back to the worksheet and enter some data into the cells you specified in the macro.
Press Enter or move to another cell to trigger the macro.
The cells you specified in the macro should now be locked, and the worksheet should be password protected.
Note that this macro only locks cells after data entry and does not prevent users from entering data into unlocked cells. Also, anyone with knowledge of VBA can view and modify the macro. Therefore, it is important to keep the password secure and to only give access to trusted users.
Subscribe link : / @hasanacademy779
Facebook group link : / 282270382269650
Facebook page link : / hasanacademybanglatutorial
Twitter Link: / mdmohiuddinhasa
Another Video link
• Excel Bangla Tutorial Tricks 51 : How to ...
• Excel Tutorial Bangla 50 : Running total a...
• Excel Tutorial Bangla 50 : Running total a...
• Excel Tutorial Bangla 48 : Auto serial wit...
• Excel VBA Bangla Tutorial 46 : Automatical...
• Excel VBA Bangla Tutorial 45 : excel surv...
• Excel VBA Bangla Tutorial 44 : Create inte...
• Excel VBA Bangla Tutorial 43 : Data prese...
• Excel Tutorial Bangla 45 : How to create i...
• Excel Tutorial Bangla 44 : Workdays Intl a...
• Excel Tutorial Bangla 42 : How to customiz...
• Excel Tutorial Bangla 41 : Sumproduct Form...