Clear contents of merged cells

Paella1

Active Member
Joined
Mar 10, 2005
Messages
382
Is there a clever way to clear the contents of merged cells without getting "Cannot change part of a merged cell" ?

The only way I can get it to work is by selecting the cell. This offends the coding gods.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

wut

Banned
Joined
Dec 13, 2010
Messages
229
Every method will fail unless you target the whole range. There's nothing wrong with changing a merged range; it's part of a merged cell you can't change
 

Paella1

Active Member
Joined
Mar 10, 2005
Messages
382

ADVERTISEMENT

The "target" is an offset from a cell that has been changed (the procedure is event triggered, so target is an unfortunate choice of terminology). It may or may not be part of merged range. I am trying to think of a way that will target the entire range if the "target" is merged.
 

Ruddles

Well-known Member
Joined
Aug 24, 2010
Messages
5,786

ADVERTISEMENT

You can do this on any part of a merged cell:-
Code:
Range([I]whatever[/I]).MergeArea.ClearContents
 
Last edited:

Paella1

Active Member
Joined
Mar 10, 2005
Messages
382
Ruddles, that is magnificent! I shall have your post embroidered on fine lace so I may pass it on to my grandchildren.
 

Ruddles

Well-known Member
Joined
Aug 24, 2010
Messages
5,786
I got it from my own dear grandmother in a very similar sort of way!
 

Watch MrExcel Video

Forum statistics

Threads
1,130,047
Messages
5,639,767
Members
417,110
Latest member
RayClarke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top