How to Flip Data Horizontally in Excel – 3 Methods

These are the sample datasets.

3 Methods to Flip Data Horizontally in Excel

 

3 Methods to Flip Data Horizontally in Excel


Method 1 – Using the Sort Command to Flip Data Horizontally in Excel

 Steps:

  • Select any cell in the dataset. 

Apply Sort Command to Flip Data Horizontally in Excel

  • Click Sort.
  • Choose Options… 

Apply Sort Command to Flip Data Horizontally in Excel

  • Check ‘Sort left to right’ and click ‘OK’.

Sort Left to Right

  • In Sort by, enter Row 5.
  • In Order, choose Smallest to Largest.
  • Click OK.

Apply Sort Command to Flip Data Horizontally in Excel

  • This is the output.

Final Table


Method 2 – Transpose Twice and Sort with a Helper Column

Steps:

  • Select the table and press Ctrl+C to copy >> right-click any cell >> go to Paste Special…

Transpose

  • Add a Helper Column.

transpose

  • Press Ctrl+C to copy the data table.
  • Check Transpose in Paste Special.

Starting Sort

  • Select the data to sort and go to Sort in the Data tab.

Sort Option

  • In Sort By, select COLUMN O.
  • In Order, choose Largest to smallest.
  • Click OK.

Repeat Transpose

  • Press Ctrl+C.
  • In Paste Special, check transpose.

Check Transpose Box

This is the output.

Final Table

Read More: How to Flip Table in Excel


Method 3 – Applying a VBA Code to Flip Data Horizontally

Steps:

  • Select the table.

Sample Data

  • Press Alt+F11.

VBA Pop up

  • Enter the VBA code below and press F5.
Sub FlipDataHorizontally()
    Dim xRng As Range
    Dim WrkRng As Range
    Dim ArY As Variant
    Dim i As Integer, j As Integer, k As Integer
    On Error Resume Next
    xTitleId = "Horizontally Flipping Data "
    Set WrkRng = Application.Selection
    Set WrkRng = Application.InputBox("Range", xTitleId, WrkRng.Address, Type:=8)
   ArY = WrkRng.Formula
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    For i = 1 To UBound(ArY, 1)
        k = UBound(ArY, 2)
        For j = 1 To UBound(ArY, 2) / 2
            xTemp = ArY(i, j)
           ArY(i, j) = ArY(i, k)
           ArY(i, k) = xTemp
            k = k - 1
        Next
    Next
   WrkRng.Formula = ArY
    Application.ScreenUpdating = True
    Application.Calculation = xlCalculationAutomatic
End Sub

This is the output.

Use VBA Code to Flip Data Horizontally


Download Practice Workbook

Download the practice workbook.


Related Articles


<< Go Back to Excel Reverse Order | Sort in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Al Ikram Amit
Al Ikram Amit

Al Ikram Amit, holding a BSc in Naval Architecture & Engineering from Bangladesh University of Engineering and Technology, serves as a key Excel & VBA Content Developer at ExcelDemy. Driven by a profound passion for research and innovation, he actively immerses himself in Excel. In his role, Amit not only skillfully addresses complex challenges but also exhibits enthusiasm and expertise in gracefully navigating tough situations, emphasizing his steadfast commitment to consistently delivering exceptional, high-quality content that adds significant... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo