View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Barb Reinhardt Barb Reinhardt is offline
external usenet poster
 
Posts: 3,355
Default vb code to clearcontents of a merged cell

For some reason, I think you could just use

r.Mergarea.clearcontents whether the mergarea.count = 1 or 10.

Barb Reinhardt

"Patrick Molloy" wrote:

you could make this a sub and pass a range to it

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

End Sub


"MitzDriver" wrote:

I have a small macro that needs to clearcontents of a merged cell. However, I
get the 1004 error of "Cannot clear contents of a merged cell". Does anyone
have a work around or some code that will unmerge, clear and merge?
Thanks in advance for any suggestions.