View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Excel Select All Visible Merged cell then Spread Cell Data

rtwiss,

Try the macro below.

HTH,
Bernie
MS Excel MVP


Sub UnMergeAllCells()

Dim myC As Range
Dim myR As Range
Dim myV As Variant
Dim myM As Range

For Each myC In ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisib le)
If myC.MergeCells Then
Set myM = myC.MergeArea
myV = myC.Value
myC.UnMerge

For Each myR In myM
myR.Value = myV
Next myR
End If
Next myC
End Sub


"rtwiss via OfficeKB.com" <u46610@uwe wrote in message
news:8b48799c482ea@uwe...
Can anyone help me with this. I have two parts of the program. Here they
a
1) Sub findmerged()
Dim c
For Each c In ActiveSheet.UsedRange
If c.MergeCells Then
MsgBox c.Address & " is merged"
End If
Next
End Sub

2) Sub Unmerge()
Dim rng As Range, rngtot As Range, rngval As Variant
Dim strtrow As Long, endrow As Long, col As Long

strtrow = Selection.Row
col = Selection.Column
endrow = Application.WorksheetFunction.Min(Selection.End(xl Down).Row -
1,
Cells(65536, col).End(xlUp).Row + 1)
rngval = Selection.Value

Set rngtot = Range(Cells(strtrow, col), Cells(endrow, col))

ActiveCell.Unmerge
For Each rng In rngtot
rng.Value = rngval
Next rng

End Sub

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200810/1