Locking a cell with VBA

R

rob nobel

I'm using the following code to replace the formula with their value .

ActiveCell.Offset(0, -6).Resize(1, 2).Value = _
ActiveCell.Offset(0, -6).Resize(1, 2).Value

How can I incorporate this code or something similar to lock those same
cells?

Rob
 
R

rob nobel

Sorry folks,
Think I've discovered the way myself.....
ActiveCell.Offset(0, -6).Resize(1, 2).Locked = True
seems to do it for me.
Though a Q still persists.
Can the locked bit be appended simply to my original code or do I need a
complete new line like that above?
Rob
 
B

Bob Phillips

Rob,

It's a new property, so has to be set individually.

You can make it a bit more efficiently like so

With ActiveCell.Offset(0, -6).Resize(1, 2)
.Value = .Value
.Locked = True
End With

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Top