Excel Quick Tips: How to Flip Cells & Switch Rows or Columns
Microsoft Excel is a powerful program that can help you analyze and visualize data. To get the best results your data needs to be in the proper format.
Occasionally you will run into data that is placed in a table, and you may not be able to work with the arrangement of rows and columns. Perhaps you have a column or row that you need to reverse entirely.
Flipping cells in a row or column can be a lot of work to do manually. Instead of re-entering all your data you can use these strategies to flip columns, turn columns into rows, and flip rows.
How to Flip Cells in Excel Columns
At first glance, there is no good way to flip columns upside down. Data sorting can sort by values or alphabetically but that doesn’t invert a column in Excel.
So what can you do? Copy the data and paste one by one? There’s a much better way to get this done.
Reversing the order of cells in a Microsoft Excel column is easy, and can be done in just a few steps with this nifty trick:
- Add a column to the left of the table you’d like to flip.
- Fill that column with numbers, starting with 1 and using the fill handle to create a series of numbers that ends at the bottom of your table.
- Select the columns and click Data > Sort. Select the column that you just added and filled with numbers. Select Largest to Smallest, and click OK.
The columns are now inverted!
This is a useful trick to add to your toolbox when you’re managing columns in Excel .
If you like working with Excel shortcuts you can perform this trick with one click. This shortcut can perform a quick sort by the leftmost column; Either by smallest-to-largest or largest-to-smallest.
The real key to all this is the index column.
Once you’ve got the data reversed you can delete the index column and you’re ready to go. This trick was done on an Excel table but it works on any number of columns you want to invert.
If you use Visual Basic (macros) with Excel , you can use this code to accomplish the same thing. Just select the column you want to flip and run this macro:
Sub FlipColumns() Dim vTop As Variant Dim vEnd As Variant Dim iStart As Integer Dim iEnd As Integer Application.ScreenUpdating = False iStart = 1 iEnd = Selection.Columns.Count Do While iStart < iEnd vTop = Selection.Columns(iStart) vEnd = Selection.Columns(iEnd) Selection.Columns(iEnd) = vTop Selection.Columns(iStart) = vEnd iStart = iStart + 1 iEnd = iEnd - 1 Loop Application.ScreenUpdating = True End Sub
VBA Macros are very useful but if you’re not comfortable with them you can get results instantly using the data sorting trick.
If VBA does pique your interest you can learn more about it with a beginner’s tutorial on writing VBA macros .
How to Switch Columns and Rows
Reversing a column has some use for data analysis but there are more ways you can manipulate data.
Another change you may want to make is switching the columns and the rows. That is, turn the column data into a row or row data into a column.
Just like inverting tables, copying and pasting information one by one is not the way to do it. Microsoft Excel has a very useful function to get this done.
- Select the columns you’d like to transpose and hit Ctrl+C or Edit > Copy.
- Click to an open cell and click Edit > Paste Special…
- Select Transpose
Your column has now been turned into a row, with the topmost value placed on the left of the row. You might have a long row so make sure you’ve got some room.
It works in the reverse order as well—you can transpose a row into a column. You can even transpose a block of data, which will turn the entire selection by 90 degrees.
How to Flip a Row in Excel
Now that you know the trick to flipping columns and you’ve seen the way to turn a column into a row; What about flipping a row in Excel?
To flip the cells in an Excel row you will use both of the tricks you learned together.
Because Microsoft Excel doesn’t support sorting rows, you’ll need to first turn the row into a column by using transpose. Once the row has been turned into a column, you can use the first trick to invert the column.
After you’ve reversed the column, transpose it back into a row and you will have inverted the entire row. It’s a rather roundabout way to get it done, but it works!
To do this in a far simpler manner, you can use Visual Basic again. Just run the same macro as before, but replace all of the instances of the word column with the word row.
Sub FlipRows() Dim vTop As Variant Dim vEnd As Variant Dim iStart As Integer Dim iEnd As Integer Application.ScreenUpdating = False iStart = 1 iEnd = Selection.Rows.Count Do While iStart < iEnd vTop = Selection.Rows(iStart) vEnd = Selection.Rows(iEnd) Selection.Rows(iEnd) = vTop Selection.Rows(iStart) = vEnd iStart = iStart + 1 iEnd = iEnd - 1 Loop Application.ScreenUpdating = True End Sub
Why Flip Rows and Columns?
Excel is widely used in data analysis. Data analysis and data visualization are becoming a critical part of decision making in many different ways.
It’s not just in computer science, data analysis is used in:
- Real Estate
- Machine Learning
Often times information used to analyze data will not be organized the way you might like. In order to get the best results, you should know how to set up data for processing.
Database tools like SQL are great for working with data, but they won’t organize your data for you. Excel can do this and give you results in Excel or Common Separated Value (CSV) files.
Knowing these tricks to flip columns and rows get you one step closer to getting the most out of your data.
Flip Data in Excel Easily
If you need to flip the data in a Microsoft Excel column or row, using one of the strategies above can save you a whole lot of time. And if you need to do it on a regular basis, using the Visual Basic macros will save you even more time. You’re ready to start getting your data to work for you!
Of course, there’s plenty more you can do with Excel. Check out these crazy Excel formulas that do amazing things or review our essential Excel formulas and functions cheat sheet .
Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.