VBA: How do I clear contents of merged cell?

Badnames

Board Regular
Joined
Jun 12, 2007
Messages
211
Hey,

I'm running a Basic Macro just to clear contents of cells. When i run it I receive an error that I cannot modify merged cells. How can I clear merged cells?

Sub servicesub()
Worksheets("Sheet1").Range("A13:O23,R26").ClearContents
Worksheets("Sheet2").Range("A13:J22,M25").ClearContents
Worksheets("Sheet3").Range("A13:J22,M26").ClearContents
Worksheets("Sheet4").Range("A13:I20,L23").ClearContents
End Sub
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
When you merge cells the reference becomes the reference of the top left cell.

So A13:O23 is really just A13
 
Upvote 0
Thanks I'll give that a go. I did a search on merged cells/vba. Looks like they cause a lot of problems.
 
Upvote 0
So got it to work on all my cells except R26. R26 is merged with R27. I chose R26 here, then tried with R27, but no luck.
 
Upvote 0

Forum statistics

Threads
1,224,550
Messages
6,179,462
Members
452,915
Latest member
hannnahheileen

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
Back
Top