You need to unprotect the sheet first before the "ws.Cells.Locked = True" statement. Then at the end of the code protect the ws again.