Sub MergeRanges()
Dim rng As Range, txt As String
For Each rng In Selection
txt = txt & rng.Value2
Next
Application.DisplayAlerts = False
Selection.Merge
Selection = txt
Application.DisplayAlerts = True
End Sub
when merge cells, i want to remain all the data in the cells. i googled some time,finding the above code. but i don’t know how to use it? and what’s the meaning of them. thank you.
Setup:
Use:
MergeRanges> RunIf you want the macro to work with “special formats” such as dates, then you should change
.Value2to.Text.