Skip to main content

How to flip / reverse a row of data order in Excel quickly?

When you need to reverse or flip the data order of a row, how can you quickly get it done? Normally you may have to use a VBA code or other Excel add-ins for doing so, because Excel doesn’t support such operation. And here comes the following tricky things will help you quickly flip or reverse a row of data order in Excel.

Flip / reverse data order horizontally in rows with VBA

Flip / reverse data order horizontally in rows with Kutools for Excel



arrow blue right bubble Flip / reverse data order horizontally in rows with VBA

Here is a neat VBA macro can help you quickly flip / reverse the data order in rows horizontally.

Step 1: Hold down the Alt + F11 keys in Excel, and it opens the Microsoft Visual Basic for Applications window.

Step 2: Click Insert > Module, and paste the following macro in the Modulewindow.

Sub FlipRows()
'Updateby20131126
Dim Rng As Range
Dim WorkRng As Range
Dim Arr As Variant
Dim i As Integer, j As Integer, k As Integer
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Arr = WorkRng.Formula
For i = 1 To UBound(Arr, 1)
    k = UBound(Arr, 2)
    For j = 1 To UBound(Arr, 2) / 2
        xTemp = Arr(i, j)
        Arr(i, j) = Arr(i, k)
        Arr(i, k) = xTemp
        k = k - 1
    Next
Next
WorkRng.Formula = Arr
End Sub

Step 3: Press the F5 key to run this macro, and a dialog is displayed for you to select a range to work with, see screenshot:

doc-reverse-order8

Step 4: Press OK, you can see the result as shown below:


arrow blue right bubble Flip /reverse data order horizontally in rows with Kutools for Excel

With Kutools for Excel’s Flip Horizontal Range tool, you can flip / reverse data order horizontally in selected rows quickly.

Kutools for Excel includes more than 300 handy Excel tools. Free to try with no limitation in 30 days. Get it Now.

Step 1: Select the row in which you will flip the data.

Step 2: Click the Kutools > Range Converter > Flip Horizontal Range, see screenshot:

doc-reverse-row-order3

Then you will see all the data order is reversed in the selected rows.

doc-reverse-row-order4
-1
doc-reverse-row-order5

Click Flip Horizontal Range to know more about this feature.


Related article:

How to flip / reverse a column of data order vertically in Excel?

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...

Description


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
Comments (7)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
In response to Rodrigo, Fbkil:

The error occurs because when you cut and paste the macro text into the Excel VBA editor, there are non-printing characters hidden in the area where the macro rows are indented. Delete them and it will work.

Note: Solved by someone else, not me. Was tricky, as it looked like it should work, but didn't.
This comment was minimized by the moderator on the site
When I try to run this macro, I get the message "syntax error" with the command line "For j = 1 To UBound(Arr, 2) / 2" highlighted in red. Does anyone know how to fix it?
This comment was minimized by the moderator on the site
got the same error. update needed
This comment was minimized by the moderator on the site
Great tool, thanks so much for VBA - I transposed a column to rows first and then used your VBA for reversing - saved tons of time!
This comment was minimized by the moderator on the site
You flipped the column order not the row order as per the title.
This comment was minimized by the moderator on the site
Copy paste (transpose) the row to column. Add 1 to x on the column beside. Filter from largest to smallest and expand. Then copy paste result and transpose to row again
This comment was minimized by the moderator on the site
A quicker way would be be to copy your selection. Right click, choose paste special. Check the transpose button, hit ok and the rows and columns will be transposed. http://office.microsoft.com/en-us/excel-help/switch-transpose-columns-and-rows-HP010224502.aspx
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations