sẵn đây góp 1 code để bạn nào chưa hiểu có thể hiểu thêm về các thuộc tính của selection:
Sub ChuyenDoi()
Dim temp As String
If Selection.Cells.Count > 2 Or Selection.Cells.Count < 2 Then
MsgBox "ban can phai chon 2 cell", vbCritical
End
End If
If Selection.Areas.Count > 1 Then
temp = Selection.Areas(1).Cells(1, 1).Value
Selection.Areas(1).Cells(1, 1).Value = Selection.Areas(2).Cells(1, 1).Value
Selection.Areas(2).Cells(1, 1).Value = temp
ElseIf Selection.Rows.Count > Selection.Columns.Count Then
temp = Selection.Range("A1").Value
Selection.Range("A1").Value = Selection.Range("A2").Value
Selection.Range("A2").Value = temp
Else
temp = Selection.Range("A1").Value
Selection.Range("A1").Value = Selection.Range("B1").Value
Selection.Range("b1").Value = temp
End If
temp = ""
End Sub