I'm reluctant to even post this and ask... as its NOT a big deal if I cant figure it out. I can live without having this worksheet protected in the way that I'd like it to be. But, since its kind of an odd-ball request, I'd thought I would post this and ask. By googling and searching this site, I was able find numerous examples of code that is close to what I am wanting it to do, but it doesnt quite work the way that i'd like it to.
Below is the code that I found that i changed around and got it to partially work the way I want it to... but... well, its doing something really strange and its got me curious as to why its doing this so maybe someone here has an answer.
Ok, so here is what I have:
The Worksheet has 3 named ranges: "RAWS", "PACKAGING" and "OTHER". What I am trying to do is lock ALL the cells on the worksheet except those that are part of one of the named ranges. (basically all the BLANK cells are going to be locked. But doing that wont quite work the way that I need it to because I have a userform that when it inserts new data it increases the named range, plus there are blank cells that might be added in by the form.)
Like I said, I have something that partially works, but it behaves... weird. (see picture below) It also only works with only 1 of the ranges (cant figure out how to add the other 2 ranges to the code.)
Ok, so here is the 'weird' part is if I click somewhere off to the right in the worksheet (away from one of the named ranges), and in the area that is PROTECTED, it wont let me type in that particular cell (which is good, thats what its supposed to do), but instead in that same row, all the over to the left, and IN that named range, what i typed shows up over there. (see picture below.)
Here is a picture that (hopefully) does a better job describing what the "weird" thing its doing than my description above...
So thanks for reading this and FREE CAKE to whoever can tell me why its doing that weird thing when I click in a protected area and type something it shows up over in the non-protected area in that same row.
(ok, disclaimer... it wont be real cake as it wouldnt stay fresh shipping it to wherever I'd need to so I will just show you a picture of somebody's tasty cake.)
Below is the code that I found that i changed around and got it to partially work the way I want it to... but... well, its doing something really strange and its got me curious as to why its doing this so maybe someone here has an answer.
Ok, so here is what I have:
The Worksheet has 3 named ranges: "RAWS", "PACKAGING" and "OTHER". What I am trying to do is lock ALL the cells on the worksheet except those that are part of one of the named ranges. (basically all the BLANK cells are going to be locked. But doing that wont quite work the way that I need it to because I have a userform that when it inserts new data it increases the named range, plus there are blank cells that might be added in by the form.)
Like I said, I have something that partially works, but it behaves... weird. (see picture below) It also only works with only 1 of the ranges (cant figure out how to add the other 2 ranges to the code.)
Ok, so here is the 'weird' part is if I click somewhere off to the right in the worksheet (away from one of the named ranges), and in the area that is PROTECTED, it wont let me type in that particular cell (which is good, thats what its supposed to do), but instead in that same row, all the over to the left, and IN that named range, what i typed shows up over there. (see picture below.)
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Worksheets("VendorList").Unprotect Password:="seatex"
Const RAWS As String = "RangeToBeLock"
With ActiveWorkbook.Worksheets("VendorList").Range("RAWS")
.Locked = False
.Parent.Protect
.Parent.EnableSelection = xlUnlockedCells
.Parent.EnableSelection = xlNoRestrictions
End With
End Sub
Here is a picture that (hopefully) does a better job describing what the "weird" thing its doing than my description above...
So thanks for reading this and FREE CAKE to whoever can tell me why its doing that weird thing when I click in a protected area and type something it shows up over in the non-protected area in that same row.
(ok, disclaimer... it wont be real cake as it wouldnt stay fresh shipping it to wherever I'd need to so I will just show you a picture of somebody's tasty cake.)
Last edited: