• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro to Lock specific Row by password

Dear All,

I am having a sheet which contains data in each row and there is a dropdown of names.
Once particular person fills the data in particlar row,it should be locked and password controlled by admin.

Ex
Row A - Data from A2 to E2,F2-person name and again data from G2-W2.
Once Particular person enters the data in A2 to W2,it should be locked (we can have dropdown as Lock/unlock in X2) to lock with password
Like that in all the rows A3,A4,A5.....

Request a macro for the same.

Thanks in advance.

Regards
 

Attachments

  • sample File.xlsx
    9.2 KB · Views: 1
I Assume this is what you want. Based on your sample. Headers start in row 2. Paste this in "ThisWorkbook" part of the file. Ensure file is .xlsm

Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

Dim CurrCell As String
CurrCell = ActiveCell.Address

Application.ScreenUpdating = False
ActiveSheet.Unprotect Password:="1"
Range("X2").Select
Do Until IsEmpty(ActiveCell)
  If ActiveCell.Value = "Lock" Then
  ActiveCell.EntireRow.Locked = True
  'Selection.FormulaHidden = False
  Range("X" & ActiveCell.Offset(1, 0).Row).Select
  Else
  ActiveCell.EntireRow.Locked = False
  'Selection.FormulaHidden = False
  Range("X" & ActiveCell.Offset(1, 0).Row).Select
  End If
Loop
Range(CurrCell).Select
ActiveSheet.Protect Password:="1"
Application.ScreenUpdating = True

End Sub
 
attached sample.xlsm.

Sheet password is 1. Auto added/removed by macro when working.
 

Attachments

  • sample File.xlsm
    18.3 KB · Views: 9
Back
Top