Help with VBA

Solved/Closed
amedotero Posts 7 Registration date Thursday November 29, 2012 Status Member Last seen December 5, 2012 - Nov 29, 2012 at 01:02 PM
amedotero Posts 7 Registration date Thursday November 29, 2012 Status Member Last seen December 5, 2012 - Dec 2, 2012 at 11:43 AM
Hello,


I'm trying to program a macro in Excell 2010. What I need it to do is look in a Range for the NotEmptyCells and change their property from Unlocked to Locked. It's my firs time working with VBA so any help will be appreciatted. Thanks!

2 responses

aquarelle Posts 7141 Registration date Saturday April 7, 2007 Status Moderator Last seen December 19, 2024 491
Nov 30, 2012 at 05:59 PM
Hello,

I put as password "12345" and I took a plage of cells "A2:C30" for example (you can change them into the macro) :

Private Sub Worksheet_Change(ByVal Target As Range) 
If Not Intersect(Target, Range("A2:C30")) Is Nothing Then 
ActiveSheet.Unprotect Password:="12345" 
Target.Locked = True 
ActiveSheet.Protect Password:="12345" 
End If 
End Sub


Regards

"Pour trouver une solution à ses problèmes, il faut s'en donner la peine."
1
amedotero Posts 7 Registration date Thursday November 29, 2012 Status Member Last seen December 5, 2012
Dec 2, 2012 at 11:43 AM
It was perfect! Thanks a lot for your help! :)
0