Javatpoint Logo
Javatpoint Logo

How to Invert Data in Excel

In Excel, inverting (or flipping) data implies rearranging rows into columns and vice versa. This adjustment is useful for rearranging datasets to better suit analysis or presentation requirements. Excel offers different methods for reversing information, including the Translate feature, Methods, and Power Question. Understanding these strategies helps clients efficiently manipulate Excel data structures to get the desired outputs.

Although there are different methods to flip the data in Excel, unfortunately, there is no built-in feature. However, you can achieve this with basic organizing tricks, formulas, or VBA.

In this tutorial, we'll the various method to effectively flip data in rows, columns, and tables in Excel.

This Tutorial Covers:

  • Flip Data Using SORT and Helper Column
  • Flip the Data Vertically (Reverse Order Upside Down)
  • Flip the Data Horizontally
  • Flip Data Using Formulas
  • Using the SORTBY function (available in Microsoft 365)
  • Using the INDEX Function
  • Flip Data Using VBA

Flip Data Using SORT and Helper Column:

One of the simplest methods to flip data in Excel is to create a helper column and then use that it to sort the data.

1. Flip the Data Vertically (Reverse Order Upside Down):

Assume you have a list of names in a column (as shown below), and you want to reverse the order of this data.

How to Invert Data in Excel

The following are the steps for flipping the information in an upward direction:

  • In the adjacent column, use 'helper' as the column header.
  • In the helper column, insert a number sequence (1,2,3, etc.). You may use the methods outlined here to do this quickly.
    How to Invert Data in Excel
  • Select the full dataset, including the helpful column.
  • Click on the Data tab.
    How to Invert Data in Excel
  • Click on the Sort icon.
    How to Invert Data in Excel
  • In the 'Sort by' dropdown, select 'Helper'.
  • From the 'Order' dropdown, choose Biggest to smallest. Click OK.
    How to Invert Data in Excel

The changes would sort the information based on the assistant column values, resulting in a switch in the request for the names in the information.


How to Invert Data in Excel
  • Erase the helper column after completion.

In this example, I showed you how to flip the information when you only have a single column. However, you can use the same approach for an entire table. Select the entire table and then use the helper column to sort the information in descending order.

2. Flip the Data Horizontally:

You can also use a similar method to flip the information horizontally in Excel.


How to Invert Data in Excel

Excel provides the option to sort the data horizontally using the Sort dialogue box (the 'Sort left to right' highlight).

Suppose me you have a table, (as given below), and need to flip the data horizontally.

The following are the steps toward do this:


How to Invert Data in Excel
  • Select the full dataset, including the helper row.
  • Click on the Data tab-> sort icon.
    How to Invert Data in Excel
  • In the Sort dialogue box, select the Options button.
    How to Invert Data in Excel
  • In the Sort exchange box, choose the Choices button. The Sort options dialogue window will appear. Click on 'Sort left or right' Click OK.
    How to Invert Data in Excel
  • In the 'Sort by' dropdown menu, select the row that contains your helper column (e.g., Row 1).
    How to Invert Data in Excel
  • Click ok. As a result, your data will be flipped.
    How to Invert Data in Excel

Flip Data using Formulas:

Microsoft 365 includes some few formulas that make it quite simple to change the request for a column or a table in Excel. In this section, I'll show you how to achieve this with the SORTBY formula (make sure to use the Excel version Microsoft 365 or above) or the Index equation (if you are using a version lower than Microsoft 365).

Let's suppose you are given a table, (as shown below), and you need to flip the information in it.


How to Invert Data in Excel

Now, use the following formula below the cell in the far left header:


How to Invert Data in Excel

Here, I've also included a third argument that shows the column number from which the value will be obtained. To make this formula dynamic, I used the column feature, which continues to adjust the column value from 1 to 3 as you copy it to one side. Once accomplished, you can convert the formula totally to values to assure a static result.

Flip Data Using the INDEX Function:

If you don't want to use the SORTBY option, you may still use the amazing List feature. Let's suppose you are given a table, (as shown below), and you need to flip the information in it.

How does the formula work?

The first formula uses the INDEX function, which returns the value of the cell based on the specified row and column number.

The real magic happens in the second parameter, where I've used the Rows function. It requires two parameters, in the first parameter the first cell reference and allowing the second reference to adjust as the formula is copied down. However, when it progresses down the columns, the primary reference changes to A3, then to A4, and so on, while the succeeding reference remains unchanged since I have locked it and made it explicit.

The following is the formula to do this:


How to Invert Data in Excel
How to Invert Data in Excel

Here, I've also included a third argument that indicates the row number from which the value should be derived. To make this dynamic, I used the row function, which will continue to adjust the row number from (1, 2, 3) as you copy it across columns. Once accomplished, you can convert the formulas totally to values to assure a consistent result.

Note: When you use a method to change the order for an informative index in Excel, the original order is not retained. If you want save initial order on the organised data, you may either apply it physically or rearrange the design from the first informative index to the new.

Flip Data Using VBA:

If you need to flip the information in Excel on a frequent basis, you may also use the VBA technique. A VBA macro code can be copied and pasted in the VBA editor and then reused with the same workbook. Additionally, you may also store the code in the separate workbook as an Excel add-in, allowing you to use it in any exercise manual on your framework.

How does this code work?

  • The code above first counts the total number of rows in the data collection and assigns the result to the variable EndNum.
  • It then utilises the Do While loop to rearrange the data. It organises the data by swapping the first and last rows, then proceeds to the second row of the second-to-last row, swapping them as well. Then this process continues to the third row of the third-to-last row, and so on.
  • The loop finishes after all of the sorting is completed. Additionally, the code sets the Application. Screen Updating attribute is set to FALSE while the code is being executed, and returned to TRUE after the code has ended. This guarantees that you do not see the changes occurring in real time on your screen while also speeding up the process.

How to use the Code?

To implement VBA code in Excel, follow the below steps:

  • Open your Excel worksheet. Hold the ALT key and hit F-11 to open the VBA editor. Alternatively, you may also click on the Developer tab and click on the Visual Basic icon.
  • Excel will open the VBA editor window for you. You'll find the project Explorer option on the left side of the window. If you don't see it, select the 'View' tab, then Project Explorer.
    How to Invert Data in Excel
  • Double-tap on the module symbol in Project Explorer to launch its code window.
  • Once the Project Explorer pane is open, paste the above VBA code in the code window.
    How to Invert Data in Excel
  • To execute the VBA code, first choose the dataset you want to flip (without the headers). With the data selected, go to the VB Supervisor and click on the green play button in the toolbar, or pick any line in the code and then press the F5 key.
    How to Invert Data in Excel
  • So these are a portion of the techniques you can use to flip the information in Excel (i.e., switch the request for the informational index).

Conclusion:

Inverting data in Excel can help organise and structure information for analytical or presentation purposes. Users may invert data to convert rows to columns and vice versa, making it easier to examine, compare, and display information.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA