Protecting merged cells via Macro

  • Thread starter Shane in Canberra
  • Start date
S

Shane in Canberra

Hi,

Hopefully a simple question. How can I change the protection on merged
cells? The following line of code gives me an error if there are merged
cells in the named range, but works fine if the named range contains no
merged cells:

range("mergedcells").locked = true


Thanks in advance
Shane
 
E

edessary

I tried this and was unable to duplicate your problem. Could you give
some additional information.
 
K

Ken Johnson

Hi Shane,
the range has to be unmerged before being locked, so try

Range("mergedcells").UnMerge
Range("mergedcells").Locked = True
Range("mergedcells").Merge

Ken Johnson
 
K

Ken Johnson

I should have used a With/End With...

With Range("mergedcells")
..Unmerge
..Locked = True
..Merge
End With

Ken Johnson
 

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

Top