On 2002-03-07 09:03, Mark O'Brien wrote:
Yeah, my bad. MS locks all of the cells be default.
Try this before locking the range:
objWS.UsedRange.Locked = False
This will unlock any cells that have data in them. If you're not constantly adding data then you can do this each time. If you are then I would suggest something like this:
objWS.Range("A1:IV65536").Locked = False
To unlock all of the cells on the sheet the first time you run.
I'm not sure of the difference in runtime for these two pieces of code, but I would stick to the first one if I had a choice.
Also, the only way to protect individual cells is to lock them and then protect the sheet. So if the sheet isn't protected, the locked cells aren't protected. As far as I know, this is a limitation in Excel.
In your code, you might just have to protect the sheet again at the end.
Like this thread? Share it with others