Land_Shark918
New Member
- Joined
- Dec 30, 2016
- Messages
- 13
I am trying to lock only certain cells in the worksheet. I have tried several different codes, and they work, except for the fact that, rather than locking only the 6 cells that I want locked, lets say, A1, A2, A3, A4, A5, & A6, the whole sheet ends up being locked. I have watched videos on it, and I'll do step for step the exact same thing, but yet my whole sheet continues to lock. Suggestions?
Here is the code I'm using
Sub LockDefaults()
Dim mainworkBook As Workbook
Set mainworkBook = ActiveWorkbook
mainworkBook.Sheets("Initial Input").Range("A1:A6").Value = "Locked"
mainworkBook.Sheets("Main").Range("A1:C5").Locked = True
ActiveSheet.Protect Password:="12345"
End Sub
Here is the code I'm using
Sub LockDefaults()
Dim mainworkBook As Workbook
Set mainworkBook = ActiveWorkbook
mainworkBook.Sheets("Initial Input").Range("A1:A6").Value = "Locked"
mainworkBook.Sheets("Main").Range("A1:C5").Locked = True
ActiveSheet.Protect Password:="12345"
End Sub