Clear Contents of Merged Cells

bamaisgreat

Well-known Member
Joined
Jan 23, 2012
Messages
831
Office Version
  1. 365
Platform
  1. Windows
Thanks all for looking. I have done some research and came up with the code below for clearing merged cells. The problem i have now is I need to add some more ranges of merged cells to the code and am unsure how. I need to add for the line with w5:x39 to carry on with more ranges.Example w5:x39,ya:ac39



Code:
Sub Clear()
'
' Clear Macro
'


Range("description").MergeArea.ClearContents
Range("job").MergeArea.ClearContents
Range("quotenum").MergeArea.ClearContents
Range("dwgnumber").MergeArea.ClearContents
Range("partnumber").MergeArea.ClearContents
Range("revisedby").MergeArea.ClearContents
Range("bomrevdt").MergeArea.ClearContents
Range("bombknumber").MergeArea.ClearContents
Range("datetoshop").MergeArea.ClearContents




Dim r As Range
Set r = Range("w5:x39")
If r.MergeCells Then
r.MergeArea.Select
r.MergeArea.UnMerge
r.ClearContents
r.Merge
Else
r.ClearContents
End If
    
End Sub
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Use a comma between the ranges. You can have all the ranges in one line.

Code:
Range("description, job, quotenum").MergeArea.ClearContents

OR

Set r = Range("W5:X39, Y12:AC39, D56:G100")
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,249
Members
452,623
Latest member
Techenthusiast

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