Locking a cell with VBA

  • Thread starter Thread starter rob nobel
  • Start date Start date
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
 
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
 
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top