How to Sort Data Alphabetically in Excel

Excel exists to bring order to the chaos of information in your spreadsheets. One of the many ways that Excel can do that is by sorting data. Scanning through data that has some sort of order is much easier, and when it comes to names and words, a popular method is to sort them alphabetically.

You can use the Sort tool to easily sort your data alphabetically in Excel. Alternatively, you can create a VBA Macro for this purpose and assign a hotkey to sort data faster.

4

Sorting Alphabetically in Excel With the Sort Tool

Excel has a built-in tool calledSortthat lets you sort your data. The Sort tool is capable of sorting data on various scales, and it also allows you to sort data alphabetically with a couple of clicks.

In this sample spreadsheet, we’ve got the names of some contractors and how much they’ve earned. The goal is to sort this table by name using the Sort tool in Excel.

A laptop with an Excel spreadsheet open and the Excel logo with a checkbox in front of the screen.

Excel will now sort your data table by the column you selected, on cell values, and in ascending order.

Sorting Alphabetically in Excel With VBA

Using VBA to sort data alphabetically in Excel can be a bit more complicated the first time, but this effort rewards you with effortlessly sorting data alphabetically later on. If you’re unfamiliar with VBA, we suggest that you read ourExcel VBA beginner’s guideto get a head start.

Let’s try and sort the data in another sample spreadsheet in Excel using VBA code. This spreadsheet includes a single column.

A laptop with Excel open, a clock on the left, and the Excel logo on the right.

Before we proceed, let’s break down this code. The first and last lines are automatically created by VBA and mark the start and finish of the macro. We named the macroAZSortin this example. If you’ve used a different name, then that name will appear instead of AZSort.

The next line defines the variableRas aRange. it’s possible to changeRto any other name you want; just remember to stay consistent throughout the code, as this variable is addressed a bunch of times in the code.

A smart TV in a living room with a muted Mic appended on top

Next, we refer to the current sheet, and then clear all previous sorting so that our new sorting can take its place. Then, we set the variableRto equal the first column of selected cells.R.Selectsimply selects the variableR.

Finally, theR.Sortline sorts the column. TheHeaderparameter indicates whether the selection includes a header or not. You can read abouthow Cells and Range differ in Excel VBAin our in-depth article. Now that you have an adequate understanding of the Macro you just wrote, let’s use it on the column.

Excel logo on a brown background.

There you have it! Although setting up the macro might take a bit more time, but from now on, all you need to do is to select the cells and press a keyboard shortcut, and Excel will sort your cells alphabetically.

Bring Order to Your Excel Spreadsheets

One of Excel’s key functions is to organize data to make them more comprehensible. One popular method of sorting names is sorting them alphabetically.

You can either use the Excel Sort tool or write a VBA code to sort alphabetically in Excel. Now that you know how to do both, it’s time to bring order to your spreadsheets!

Simple code is vital for Microsoft Excel power users. But how can you make or safely exit a for loop using VBA in Excel?

It saves me hours and keeps my sanity intact.

Sometimes the smallest cleaning habit makes the biggest mess.

check that you don’t miss these movies and shows before Netflix removes them.

So much time invested, and for what?

My iPhone does it all, but I still need my dumb phone.

Technology Explained

PC & Mobile