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.
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.
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
WorkRng.Formula = Arr
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:
Step 4: Press OK, you can see the result as shown below:
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:
Then you will see all the data order is reversed in the selected rows.
Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
More than 300 powerful features. Supports Office/Excel
2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features
30-day free trial. 60-day money back guarantee.
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.
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