Lock a row, then un-lock individual cells?
Posted on 2012-09-19
Hello - I've got a situation where I am reading rows from a recordset and putting the field values into cells on a worksheet.
These rows represent budget allocations; if the status of a given allocation is "Active", then the user can change certain fields on the row; otherwise; they can't change anything; it's just there for reference.
So I have this code:
(after the code to insert a row, and set it as a range called "rngInsert")
'-- transfer the values from the recordset fields into the worksheet cells
.Cells(1, 1).Value = rst![ProjactName]
.Cells(1, 2).Value = rst![ProjectNumber]
.Cells(1, 3).Value = rst![StatusDesc]
.Cells(1, 4).Value = rst![Qty]
.Cells(1, 5).Value = rst![CapAmt]
.Cells(1, 6).Value = rst![ExpAmt]
'-- lock the entire row, but if the allocation is still active, open up the amount fields
.Locked = True
If rst![StatusDesc] <> "Closed" Then
.Cells(1, 4).Locked = False
.Cells(1, 5).Locked = False
.Cells(1, 6).Locked = False
It's not working; all the cells are still locked for rows where the status is active. I've stepped through it in the debugger; the ".Locked = False" lines are getting executed when they should.
Am I leaving something out? (I *am* remembering to protect the worksheet after this routine runs)