Hello,
I would like to protect 3 columns using VBA. Protection should go as long as there is data.
I measure the end of my data in column A and to find the last row I use:
Now, to protect 3 columns I used this code, but it doesn't work.
I appreciate any help on this.
I would like to protect 3 columns using VBA. Protection should go as long as there is data.
I measure the end of my data in column A and to find the last row I use:
Code:
LastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
Now, to protect 3 columns I used this code, but it doesn't work.
Code:
ws.Unprotect Password:="123"
ws.Cells.Locked = False
ws.Range("C" & LastRow).Locked = True
ws.Range("D" & LastRow).Locked = True
ws.Range("E" & LastRow).Locked = True
ws.Protect Password:="123", UserInterFaceOnly:=True
I appreciate any help on this.