Clearing Merged Cells

R

Risky Dave

Hi,

I have a range of cells that I need to clear before doing other stuff with
them. These cells are formatted in a particular way and some of them are
merged. I am trying to use:

Sheets("mobilisation").Range("h2:n8").Clear

but this is returning an error saying that Excel "cannnot change part of a
merged cell"

As I can both Clear and Delete the content of these cells manually, I assume
that I haven't got the syntax correct to do it in VBA?

Any help would be appreciated.

TIA

Dave
 
B

Barb Reinhardt

Try

Sheets("mobilisation").Range("h2:n8").MergeArea.Clear

HTH,
Barb Reinhardt
 
R

Risky Dave

Barb,

thanks for the reply. this now throws up:

Run-time error 1004:

Application-defined or object-defined error


As you have probably guessed, I'm no programmer so I don't really understand
what this is trying to tell me.

Dave
 
J

JLGWhiz

I should have included that after the cells are unmerged, you can then clear
them. If you require merged cells in that range, then you will have to
merge them again.

Excel will not let you alter merged cells because it does not know which
part of the cell you really want to change. You have to unmerge them, do
your thing and then merge them again.
 

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