Sub MergeCells()
Dim ra As Range, i As Long, iR As Long, iC As Long, sTemp As String
With Application
Set ra = Selection
If ra.Cells.Count = 1 Then
On Error Resume Next
Set ra = .InputBox(Prompt:="Chon vung can tron o", Title:="Merge Cells", Type:=8)
On Error GoTo 0
End If
If ra Is Nothing Then Exit Sub
iR = ra.Rows.Count
iC = ra.Columns.Count
For i = 1 To iR
sTemp = ""
For j = 1 To iC
If ra(i, j) <> "" Then sTemp = sTemp & Chr(10) & Chr(13) & ra(i, j)
Next
If Left(sTemp, 2) = Chr(10) + Chr(13) Then sTemp = Right(sTemp, Len(sTemp) - 2)
.DisplayAlerts = False
ra.Rows(i).Merge
.DisplayAlerts = True
ra.Rows(i) = sTemp
ra.Rows(i).HorizontalAlignment = xlCenter
Next
End With
End Sub