Sub swapRows()
Dim xlong As Long
If Selection.Areas.Count <> 2 Then
MsgBox "Phai co chinh xac hai vung the doi cho." & Chr(10) _
& "Ban co " & Selection.Areas.Count & " vung."
Exit Sub
End If
If Selection.Areas(1).Columns.Count <> Cells.Columns.Count Or _
Selection.Areas(2).Columns.Count <> Cells.Columns.Count Then
MsgBox "Must select entire Rows, insufficient columns"
Exit Sub
End If
Dim areaSwap1 As Range, areaSwap2 As Range, onepast2 As Range
If Selection.Areas(1)(1).Row > Selection.Areas(2)(1).Row Then
Range(Selection.Areas(2).Address & "," & Selection.Areas(1).Address).Select
Selection.Areas(2).Activate
End If
Set areaSwap1 = Selection.Areas(1)
Set areaSwap2 = Selection.Areas(2)
Set onepast2 = areaSwap2.Offset(areaSwap2.Rows.Count, 0).EntireRow
areaSwap2.Cut
areaSwap1.Resize(1).EntireRow.Insert Shift:=xlShiftDown
areaSwap1.Cut
onepast2.Resize(1).EntireRow.Insert Shift:=xlShiftDown
Range(areaSwap1.Address & "," & areaSwap2.Address).Select
xlong = ActiveSheet.UsedRange.Columns.Count correct lastcell
End Sub