Skip to main content

AndAdd the following macros to your Personal Macro Workbook and assign them shortcut keys. The behaviour mimics Sublime Text's Swap Line Up & Swap Line Down.

Sub move_rows_down()
    Dim rOriginalSelection As Range
    Set rOriginalSelection = Selection.EntireRow
    With rOriginalSelection
        .Select
        .Cut
        .Offset(rOriginalSelection.rows.Count + 1, 0).Select
    End With
    Selection.Insert
    rOriginalSelection.Select
End Sub

Sub move_rows_up()
    Dim rOriginalSelection As Range
    Set rOriginalSelection = Selection.EntireRow
    With rOriginalSelection
        .Select
        .Cut
        .Offset(-1, 0).Select
    End With
    Selection.Insert
    rOriginalSelection.Select
End Sub

And the following to your Personal Macro Workbook and assign them shortcut keys. The behaviour mimics Sublime Text's Swap Line Up & Swap Line Down.

Sub move_rows_down()
    Dim rOriginalSelection As Range
    Set rOriginalSelection = Selection.EntireRow
    With rOriginalSelection
        .Select
        .Cut
        .Offset(rOriginalSelection.rows.Count + 1, 0).Select
    End With
    Selection.Insert
    rOriginalSelection.Select
End Sub

Sub move_rows_up()
    Dim rOriginalSelection As Range
    Set rOriginalSelection = Selection.EntireRow
    With rOriginalSelection
        .Select
        .Cut
        .Offset(-1, 0).Select
    End With
    Selection.Insert
    rOriginalSelection.Select
End Sub

Add the following macros to your Personal Macro Workbook and assign them shortcut keys. The behaviour mimics Sublime Text's Swap Line Up & Swap Line Down.

Sub move_rows_down()
    Dim rOriginalSelection As Range
    Set rOriginalSelection = Selection.EntireRow
    With rOriginalSelection
        .Select
        .Cut
        .Offset(rOriginalSelection.rows.Count + 1, 0).Select
    End With
    Selection.Insert
    rOriginalSelection.Select
End Sub

Sub move_rows_up()
    Dim rOriginalSelection As Range
    Set rOriginalSelection = Selection.EntireRow
    With rOriginalSelection
        .Select
        .Cut
        .Offset(-1, 0).Select
    End With
    Selection.Insert
    rOriginalSelection.Select
End Sub
now supports multiple rows!
Source Link
tjmcewan
  • 408
  • 6
  • 9

And the following to your Personal Macro Workbook and assign them shortcut keys. The behaviour mimics Sublime Text's Swap Line Up & Swap Line Down.

Sub move_row_downmove_rows_down()
    ActiveCellDim rOriginalSelection As Range
    Set rOriginalSelection = Selection.EntireRow
    With rOriginalSelection
        .Select
    Selection    .Cut
    ActiveCell    .Offset(2rOriginalSelection.rows.Count + 1, 0).Select
    End With
    Selection.Insert
    ActiveCell.Offset(-1, 0).EntireRowrOriginalSelection.Select
End Sub

Sub move_row_upmove_rows_up()
    ActiveCellDim rOriginalSelection As Range
    Set rOriginalSelection = Selection.EntireRow
    With rOriginalSelection
        .Select
    Selection    .Cut
    ActiveCell    .Offset(-1, 0).EntireRow.Select
    End With
    Selection.Insert
    rOriginalSelection.Select
End Sub

And the following to your Personal Macro Workbook and assign them shortcut keys. The behaviour mimics Sublime Text's Swap Line Up & Swap Line Down.

Sub move_row_down()
    ActiveCell.EntireRow.Select
    Selection.Cut
    ActiveCell.Offset(2, 0).Select
    Selection.Insert
    ActiveCell.Offset(-1, 0).EntireRow.Select
End Sub

Sub move_row_up()
    ActiveCell.EntireRow.Select
    Selection.Cut
    ActiveCell.Offset(-1, 0).EntireRow.Select
    Selection.Insert
End Sub

And the following to your Personal Macro Workbook and assign them shortcut keys. The behaviour mimics Sublime Text's Swap Line Up & Swap Line Down.

Sub move_rows_down()
    Dim rOriginalSelection As Range
    Set rOriginalSelection = Selection.EntireRow
    With rOriginalSelection
        .Select
        .Cut
        .Offset(rOriginalSelection.rows.Count + 1, 0).Select
    End With
    Selection.Insert
    rOriginalSelection.Select
End Sub

Sub move_rows_up()
    Dim rOriginalSelection As Range
    Set rOriginalSelection = Selection.EntireRow
    With rOriginalSelection
        .Select
        .Cut
        .Offset(-1, 0).Select
    End With
    Selection.Insert
    rOriginalSelection.Select
End Sub
Source Link
tjmcewan
  • 408
  • 6
  • 9

And the following to your Personal Macro Workbook and assign them shortcut keys. The behaviour mimics Sublime Text's Swap Line Up & Swap Line Down.

Sub move_row_down()
    ActiveCell.EntireRow.Select
    Selection.Cut
    ActiveCell.Offset(2, 0).Select
    Selection.Insert
    ActiveCell.Offset(-1, 0).EntireRow.Select
End Sub

Sub move_row_up()
    ActiveCell.EntireRow.Select
    Selection.Cut
    ActiveCell.Offset(-1, 0).EntireRow.Select
    Selection.Insert
End Sub
Post Made Community Wiki by tjmcewan