• Computers & Internet >
  • Software
  • Computers & Internet >
  • Software

Protect sheet using following vba code with "do not select locked cells"?

  • Follow publicly
  • Follow privately
  • Unfollow
its not work when i open the work book then "do not select locked cell" is not work but when i enter the data on target cell then its work perfectly and some time the all ...show more
Best Answer
  • KALL answered 7 years ago
protect sheet using following vba code with "do not select locked cells"?
its not work when i open the work book then "do not select locked cell" is not work but when i enter the data on target cell then its work perfectly and some time the all vba code has not work.i use excel 2007.
Any can solve this?



Option Explicit

Private Sub WORKSHEET_CHANGE(ByVal TARGET As Range)
Dim wsSD As Worksheet
Dim wsS As Worksheet
Set wsSD = Sheets("DATA")
Set wsS = Sheets("STCC")
If TARGET.Address = "$L$171" Then
Sheets("STCC").Unprotect Password:="password"
wsS.Range("L172").Value = ""
wsSD.Range("Database").AdvancedFilter _
Action:=xlFilterCopy, _
CriteriaRange:=wsS.Range("L170:L171"), _
CopyToRange:=wsS.Range("AC110"), Unique:=True
ActiveSheet.EnableSelection = xlUnlockedCells
Sheets("STCC").Protect DrawingObjects:=True, CONTENTS:=True, Scenarios:=True, Password:="password"

End If
End Sub
Sign In 

to add your answer

Who is following this question?

    %
    BEST ANSWERS
    Member Since:
    Points: Points: Level
    Total Answers:
    Points this week:
    Follow
     
    Unfollow
     
    Block
     
    Unblock