Clear Contents of Merged Cells

bamaisgreat

Well-known Member
Joined
Jan 23, 2012
Messages
821
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

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
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,214,918
Messages
6,122,252
Members
449,075
Latest member
staticfluids

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