Macro Help

  • Thread starter Thread starter MDMeyers
  • Start date Start date
M

MDMeyers

Using this macro, I get syntax error. Tryng to combine merged cells so
I can graph data.

Sub UnMergeTest()
Dim C As Range, CC As Range
Dim MA As Range, RepeatVal As Variant

For Each C In Range(ActiveCell, Cells(Rows.Count,
ActiveCell.Column).End(xlUp))
If C.MergeCells = True Then
Set MA = C.MergeArea
If RepeatVal = "" Then RepeatVal = C.Value
MA.MergeCells = False
For Each CC In MA
CC.Value = RepeatVal
Next
End If
RepeatVal = ""
Next
End Sub

Thanks in advance for help.
 
Try

Sub UnMergeTest()
Dim C As Range, CC As Range
Dim MA As Range, RepeatVal As Variant

For Each C In Range(ActiveCell, Cells(Rows.Count, _
ActiveCell.Column).End(xlUp))
If C.MergeCells = True Then
Set MA = C.MergeArea
If RepeatVal = "" Then RepeatVal = C.Value
MA.MergeCells = False
For Each CC In MA
CC.Value = RepeatVal
Next
End If
RepeatVal = ""
Next
End Sub



--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top