You’re reorganizing data sets, restructuring tables, or simply adjusting the layout, you often need to move rows in your worksheet up and down or right and left. If you know how to move a row in Excel, such tasks become effortless.
Microsoft Excel doesn’t offer any dedicated ribbon commands to move rows the way you want. You must use a combination of keyboard shortcuts, mouse movements, and indirect ribbon commands to achieve this feat.
Read this article until the end to discover multiple ways to move a row so you can choose a method that suits your worksheet and its datasets. Let’s begin!
Move a Row Using a Drag and Drop Movement
This is the easiest way to move a row in any direction, like up, down, right, and left.
Highlight the target row by selecting the exact number of cells containing data. This is beneficial if you wish to avoid replacing other cell ranges in a different table of the same row.
You shall see a thick green border around the selected cell range. Hover the mouse cursor over the thick border to activate the row movement cursor. It’s the cursor with four arrows pointing outwards.
You can now drag the mouse to the left, right, up, and down to move the row where you want. When dragging, you shall see a silhouette of the dragged cell range.
When moving, you shall also see the new cell range address for the data after the moving is complete.
Let go of the mouse click to place the cell range on its destination.
If data already exists in the destination cell range where you’re moving a row of data, Excel shall ask you to confirm whether you want to replace the data or not.
If you choose OK, the old data shall be updated with the data from the row you’re moving.
Contrarily, if you choose Cancel, the row movement shall be aborted by Excel.
Suppose, you want to move the entire row by selecting all the cells between columns A and XFD, you can follow the same drag-and-drop movement as explained above.
However, in this scenario, you won’t be able to move the row to the left or right. Only up and down movements are allowed when moving the entire row in Excel.
๐ Read More: How Many Rows Can Excel Handle?
Using Shift + Drag
If you wish to manually place a row between two rows in an Excel dataset or table, you can use this method.
Highlight the target cell range or row on your worksheet.
Press the Shift key on the keyboard.
Now, activate the movement cursor by following the steps mentioned earlier.
Start dragging the row or cell range up, down, left, or right to relocate it.
You shall see a thick border between two contiguous rows in the worksheet.
If you’ve found the destination, let go of the mouse click and the Shift key.
Move a Row in Excel Using the Ctrl Key
This is the fastest way to move a row.
Simply highlight the row you want to move and press the Ctrl key.
Now, hover the mouse cursor over the up or down border of the row to activate the moving icon.
If you’ve selected a cell range within a row, you can move the selection left, right, up, and down.
Contrarily, if you’ve selected the entire row, you can only move it up or down.
Go to the destination row and release the mouse click to place the selected row.
If you place the cell range on a row where data already exists, Excel shall replace the old dataset without showing a warning message.
When you move a row using this method, you create a copy of the selected row.
Move a Row in Excel Using Copy and Paste
You can simply highlight the row or a cell range from the row and press Ctrl + C to copy the content.
Then, go to the destination row and press Ctrl + V to move the row there. If the destination cell range has any old data, Excel shall update that without any prompt.
However, this method is beneficial in another way. Suppose, you’d like to move 5 non-contiguous rows from a table into another table or cell range in a contiguous manner. You can do so by using this method.
Select the target rows in the source table. Since these rows are non-contiguous, you must press the Ctrl key.
Now, go to the destination cell range and press Ctrl + V to move the rows in continuation.
Move a Row in Excel Using Insert Cut Cells
If you wish to change the position of rows in a table or cell range to organize your dataset in a better way, you can use this method.
In the above dataset, I need to move the 2nd row above the 8th row without changing the values of the dataset or deleting a row.
So, I’d select the target row and press Ctrl + X.
Then, I’d select the 8th row in the dataset and right-click to bring up the context menu. There, I select the Insert Cut Cells function.
Excel shall move the 7th row to the 6th position and replace the blank space of the 7th row with the 2nd row.
You can also follow this method to move multiple contiguous rows to a different position in the table.
However, this technique won’t work on multiple non-contiguous cells.
Move a Row in Excel Using a Sort Criteria
The Sort & Filter tool also allows you to move rows up or down using sorting criteria. If your sort by cells contains text strings, then the sorting criteria available to you are A to Z and Z to A.
Alternatively, if the sort by column contains numerical values, you can apply sorting criteria like Smallest to Largest and Largest to Smallest.
Suppose, in the above dataset, you want to move the candidate’s row containing the heights score to the top, then 2nd, 3rd, and so on.
Select the column header text and press Ctrl + Shift + L to activate the Sort & Filter tool.
Now, click the drop-down arrow for the sorting criteria and choose the Smallest to Largest option.
Excel shall quickly re-arrange the table from the largest value to the smallest value in the Score column.
Move a Row in Excel Using the SORT Function
Another smart way to move rows up or down is by using the Excel SORT formula.
Suppose, you’d like to move the row that contains the highest stock price to the top of the table. Then, you want the stock scoring the 2nd highest price, and so on.
You can select the cell C2
and enter the following formula:
=SORT(A2:B6,2,-1)
Press Enter to apply the formula to sort the input dataset in an array of data. If you’re using any Excel desktop app below Excel for Microsoft 365, you must press Ctrl + Shift + Enter.
In the above formula, the cell range represents the data table you’re sorting. So, adjust this according to your own worksheet.
Then, you must enter the column number by which you want to sort the input dataset. In this example, it’s the Score column, which is number 2
in the table.
The value -1
in the formula tells Excel to sort the dataset in descending order. If you want this to be in ascending order, input 1
.
Under columns C and D, you shall get the sorted dataset.
The dataset shall change dynamically if you change the input values.
To preserve the values only, copy the array dataset using Ctrl + C.
Go to the destination cell range, press Ctrl + Alt + V, and choose Values inside the Paste section of the Paste Special dialog.
Finally, delete columns C and D to complete the process of moving rows up and down by values.
Move a Row in Excel Using Excel VBA
If you wish to programmatically move one or many rows in an Excel dataset with visual queues, you can use Excel VBA. Here’s the script you can use:
Sub MoveRows()
Dim rng As Range
Dim destRow As Long
Dim ws As Worksheet
' Set the worksheet
Set ws = ActiveSheet
' Prompt the user to select rows
On Error Resume Next
Set rng = Application.InputBox("Select rows to move", Type:=8)
On Error GoTo 0
' Check if the user canceled the operation
If rng Is Nothing Then Exit Sub
' Prompt the user to enter the destination row number
destRow = Application.InputBox("Enter the row number where you want to move the selected rows", Type:=1)
' Check if the user canceled the operation
If destRow = 0 Then Exit Sub
' Move the rows
rng.Cut Destination:=ws.Cells(destRow, 1)
MsgBox "Rows moved successfully!", vbInformation
End Sub
Find out how to create a VBA macro by checking out the following Excel tutorial:
๐ Read More: How To Use The VBA Code You Find Online
Now that you’ve successfully created a VBA macro, press Alt + F8 to access the Macro dialog. There, select the MoveRows macro and hit the Run button.
When an input box shows up, enter the row numbers or cell ranges you want to move. You can use commas between two rows or cell range addresses to move multiple rows.
In the next prompt, enter the row number or address where you want to move these rows or cell ranges.
If you provide the input values correctly, Excel shall automatically move the rows you’ve selected.
Move a Row in Excel Mobile App
Just like the Excel desktop app, there aren’t any straightforward commands in the Excel ribbon menu to move rows. You need to perform a drag-and-drop movement to move rows wherever you want.
Firstly, open your Excel worksheet in the Excel mobile app.
Now, select the row or cell range of a row that you want to move anywhere on the worksheet.
Longpress on the selected row to activate the row movement action.
Drag the row to the destination cell range to move the cell range.
If there is old data in the destination cell range, Excel shall ask you whether you want to replace the data or not.
If you’re using the Excel mobile app on an Android smartphone, you can follow the same steps to move a row.
Conclusions
If you’ve made it here, you’ve learned 9 different methods to move a row in Excel. You can try out the method that suits your Excel expertise level and according to the exact problem you’re solving in your worksheet.
Among all the techniques that involve manual movements and functions, the best solution is using the Excel VBA method. It guides you through the entire row-moving process with input boxes so that you can achieve the best results.
If the article helped you, you can share your feedback here. Contrarily, if you know a different method to move a row, mention that in your comment.
0 Comments