im trying to select cell B4 and all the cells from column A to Z and row 10 and below, so basically A10:Z150. And trying to unlocked it before i protect the sheet. Right now im using Sheets("DR02").Range("B4", "A10:Z200").Locked = False but its not working. Its only unlocking cells above row 4 instead of only cell B4.
2 Answers
0
votes
Try to use:
With Sheets("DR02")
.Unprotect "password"
.Range("B4,A10:Z200").Locked = False
.protect "password"
End With
Or (to get the last row in column "A"):
With Sheets("DR02")
.Unprotect "password"
.Range("B4,A10:Z" & .Range("A" & .Rows.Count).End(xlUp).Row).Locked = False
.protect "password"
End With
EDIT:
From comments it seems that cell B4
is merged with other cells if so then we can use:
With Sheets("DR02")
.Unprotect "password"
Union(.Range("B4").MergeArea, .Range("A10:Z" & .Range("A" & .Rows.Count).End(xlUp).Row)).Locked = False
.Protect "password"
End With