• Latest
  • Trending

How to use shortcuts to sort in Microsoft Excel

December 7, 2020

Business booms for lawncare service started by three Saginaw boys | News

August 2, 2021

MSP seizes more than 1,200 marijuana plants from Carrolton Twp. home | News

August 2, 2021

The Hour Glass and Rolex: Partners in Time

August 2, 2021

Ocon claims maiden victory, Vettel disqualified

August 2, 2021

Midstate mom combats medical trauma in kids | 4 Your Community

August 1, 2021

Binance NFT celebrates Elephant Day with inaugural Jim Thompson NFTs

August 1, 2021

North Kansas City mask order starts Monday | Coronavirus

August 1, 2021

Father-son duo kayak the Chesapeake Bay in support of families in need

August 1, 2021

NWS confirms at least six tornadoes across Wisconsin from Wednesday night storms

July 31, 2021

Crete athlete struggles with post-COVID syndrome | Health and Fitness

July 31, 2021

In this rural Missouri county, the vaccination rate is low and opposition high | Coronavirus

July 31, 2021

The “Serendipity Sapphire” is the World’s Largest Sapphire Cluster

July 30, 2021
  • Home
  • General News
  • Tech
  • Entertainment
  • Lifestyle
Tuesday, August 16, 2022
10Newz
  • Home
  • General News
    • All
    • Politics

    Trump’s Antifa Obsession Drew Law Enforcement Away From Far-Right

    Biden Executive Order Expands Obamacare to Uninsured in Pandemic

    Economy closes out 2020 with lower than expected 4% gain

    Cuba Fast Facts

    Expect “at least another 10 weeks” of vaccine shortages, says German Health Minister

    Comcast (CMCSA) Q4 2020 earnings

    Everything you need to know about how a Reddit group blew up GameStop's stock

    Could post-vaccine life mean we return to normal? Not just yet

    Dr. Fauci says Covid vaccines can be easily adapted to new variants, drugmakers working on boosters

    Poland abortion law: New restrictions go into effect, resulting in a near-total ban on terminations

    Trending Tags

    • Donald Trump
    • Future of News
    • Climate Change
    • Market Stories
    • Election Results
    • Flat Earth
  • Tech

    NFKings Co-founder Matthew Lim on NFTs and Binance Investment

    Virgin Galactic founder Richard Branson successfully rockets to outer space

    Twitter is a mess in India. Here’s how it got there

    Online retailers are using AI to convert more shoppers into buyers

    What Apple users should expect when using Microsoft 365 subscriptions

    Google Drive for Desktop app: 4 reasons why you should install it

    AI is trying to prevent online shoppers from ditching their carts

    Everything you need to know about Richard Branson going to space this weekend

    What Windows 11 means for Windows on Arm, and why it will bring more big name apps

    Apple co-founder Steve Wozniak: ‘It’s time to recognize the right to repair’

    Trending Tags

    • Flat Earth
    • Sillicon Valley
    • Mr. Robot
    • MotoGP 2017
    • Golden Globes
    • Future of News
  • Entertainment
    • All
    • Gaming
    • Music
    • Sports

    The Inside Story of How Navalny Uncovered Putin’s Palace

    Ducks fly together in new trailer for Disney+ series ‘The Mighty Ducks: Game Changers’

    Sophie Is Gone, and It’s Okay to Cry

    Johnson & Johnson Publishes Promising COVID-19 Vaccine Data

    Hollywood pays tribute to Cicely Tyson

    Trump’s Antifa Obsession Drew Law Enforcement Away From Far-Right

    CDC Issues Mask Mandate for Public Transportation and Planes

    Cicely Tyson’s radiant power (opinion)

    Watch System of a Down’s New Video for ‘Genocidal Humanoidz’

    Police Tighten Congress Security in Era of Rising Threats

  • Lifestyle
    • All
    • Fashion
    • Travel

    The Hour Glass and Rolex: Partners in Time

    Ocon claims maiden victory, Vettel disqualified

    Binance NFT celebrates Elephant Day with inaugural Jim Thompson NFTs

    The “Serendipity Sapphire” is the World’s Largest Sapphire Cluster

    Latest Saint Laurent Rive Droite Collection Features Jean Michel Basquiat

    NFKings Co-founder Matthew Lim on NFTs and Binance Investment

    Favourite Pieces from Watches & Wonders 2021: WOW Thailand Editor

    Sydney Leads The World With Its Placemaking Projects

    Sustainability, Market Demand and Unexpected Watches

    Tabayer Takes an Introspective Approach Ahead of the Collection Launch

    Trending Tags

    • Golden Globes
    • Mr. Robot
    • MotoGP 2017
    • Climate Change
    • Flat Earth
No Result
View All Result
News
No Result
View All Result
Home Tech

How to use shortcuts to sort in Microsoft Excel

by admin
December 7, 2020
in Tech
0
491
SHARES
1.4k
VIEWS
Share on FacebookShare on Twitter

[ad_1]

If you run sorts in Excel a lot, you might benefit from shortcuts or even a macro. Here are some ways to make your sorting life easier.

Pointing at spreadsheet on laptop

Image: Aajan, Getty Images/iStockphoto

Sorting data is easy and for the most part, Microsoft Excel offers a number of ways, including keyboard shortcuts, to get the job done. For the most part, we run so many simple sorts that we think nothing of it. However, once you get into sorting multiple columns, a sort requires more clicks and choices. It’s still easy, but it can stop you in your tracks and some users don’t like to slow down that much. First, I’ll show you how to find some keyboard shortcuts for one-column sorts. Then, we’ll look at a macro that runs a two-column sort.

SEE: 60 Excel tips every user should master 

I’m using Microsoft 365 on a Windows 10 64-bit system, but you can use older versions. You can work with your own data or download the demonstration .xlsm and .bas files. This article isn’t appropriate for the browser version.

How to do a single-column sort in Excel

Even the newest of users can run a simple ascending or descending sort on a single column. Click anywhere inside the column you want to sort by and click one of the Sort options in the Sort & Filter on group on the Data tab. On the Home tab, you can click Sort & Filter in the Editing group. Or you can right-click the cell, click Sort, and then click the appropriate option from the resulting submenu. Figure A shows an ascending sort on the Num field.

Figure A

excelcustomsort-a.jpg

  Use the tab options or shortcut menu to access sort options.

Sorting shortcuts can do the same thing without removing your hands from the keyboard: With the cursor anywhere in the column you want to sort by (within the data set, of course), press Alt-A-S-A for an ascending sort and Alt-A-S-D for a descending sort. To take the Home tab route, press Alt-H-S-S and Alt-H-S-O. (These shortcuts are harder to remember.) Now that you know the basics, we can move on to multi-column sorts.

SEE: How to easily include dynamic dates in a Word doc using Excel (TechRepublic)

How to do a multi-column sort in Excel

When sorting by multiple columns, you’re grouping. For instance, to sort our demonstration sheet by Num and then Place means to sort the Num values and then sort the Place values within the Num group. Review Figure A and you can see that the values in the Place field are not sorted within each group—any time they are, it’s a coincidence. Figure B shows the 2 group in the Num field, the Place values are 3, 1, 3, in that order, which is no order at all.

Figure B

excelcustomsort-abjpg.jpg

You need a sort for more than one column. You can open the Sort dialog by clicking the Sort option in the Sort & Filter group on the Data tab, or by clicking Sort & Filter in the Editing group on the Home tab. Fortunately, the shortcut keystrokes are easy to remember: Alt-A-S-S and Alt-H-D-U. Both open the dialog shown in Figure C.

Figure C

excelcustomsort-c.jpg

  The Sort dialog let’s you add columns.

Using this dialog, you can sort by multiple columns. First, you should take a look at the My Data Has Headers option. You must set this option properly to get the expected results. If you don’t set it and the data set has headers, Excel sorts the header text with the values.

SEE: 3 ways to suppress zero in Excel (TechRepublic)

Now, let’s work out our two-column sort using this dialog:

  1. The My Data Has Headers option is checked. (Excel tries to discern this value for you, but sometimes you will have to reset it.)
  2. As you can see in Figure C, the settings are already correct. That’s because Excel remembers the last sort, which in our case, was an ascending sort on the Num field. If necessary, choose Num from the Sort by dropdown. 
  3. Click Add Level to add the Place field.
  4. From the Then By dropdown choose Place. Again, Excel does a good job of choosing the other options, which we’ll retain (see Figure D). Notice that you could change the order to descending. The language—Then By—makes it clear that you’re adding a subset, or group, to the sort.
  5. Click OK.

Figure D

excelcustomsort-d.jpg

  Add a second sort, or grouping field. 

As you can see in Figure E, the Places values to the right of the 2 group in the Num values are now in ascending order—1, 3, and 3. In our simple data set, there’s not much else to sort by other than the dates, but we could do so—sorting by three columns. How you add them to the sort will determine the results. Remember that each Then By level is a subset of the previous sort or grouping.

Figure E

excelcustomsort-e.jpg

  The Place values sort within the Num groups.

You might have noticed that I didn’t use any kind of keystroke to add the Place column to the original sort. That’s because you can’t. To the best of my knowledge, what I’ve shown you is as far as you can get with shortcuts. However, I did promise a keyboard shortcut solution and for that, you’ll need a macro.

How to use a macro to sort in Excel

If a multi-column sort is a frequent task for you, consider a macro and then assign a keyboard shortcut to run it, or add it to a custom group or even the Quick Access Toolbar (QAT). I’ll show you the macro and you can decide how to run it.

SEE: How to use Find All to manipulate specific matching values in Excel (TechRepublic)

Listing A shows a macro that automates the simple two-column sort that we ran in the last section. It’s not dynamic—it only runs this one simple sort. But you can easily adapt it to suit your needs. To enter the VBA procedure, open the Visual Basic Editor (VBE) window by pressing Alt+F11. From the Insert menu, choose Module and enter the code. Don’t copy and paste the code from this web page—it won’t work. Enter it manually or copy from the .bas file included with the downloadable demonstration files. If you must copy from this web page, paste it into Word or another word editor and the paste from there into the VBE; doing so removes web characters that you can’t see.

Listing A

Sub SortMultipleColumns()

‘Sort columns D and E; Num (D) is the primary sort; Place (E) is the first grouped sort).

  With ActiveSheet.Sort

    .SortFields.Clear

    .SortFields.Add Key:=Range(“D2”), Order:=xlAscending

    .SortFields.Add Key:=Range(“E2”), Order:=xlAscending

    .SetRange Range(“B2:E16”)

    .Header = xlYes

    .Apply

  End With

End Sub

When you return to Excel, save the workbook as a macro-enabled file (.xlsm). If you’re using an older menu version (.xls), this step isn’t required.

The macro itself needs little explanation, but you can add levels using the Add method. In addition, you must run the Clear method at the beginning to remove the previous sort. You can add one afterward, too (after the Apply method), if you don’t want Excel to remember it. The commented line uses the Table reference if you want to go that route; a Table will allow you to add and delete rows of data without updating the data range in the macro.

Right now, the macro isn’t accessible with a keystroke shortcut, so let’s take care of that next:

  1. Click the Developer tab and then click Macros in the Code group.
  2. Select the procedure, SetMultipleColumns, if necessary.
  3. Click the Options button.
  4. In the resulting window, create a macro shortcut, by entering a key to press, along with Ctrl. As you can see in Figure F, I entered S, for sort.
  5. Click OK and then Cancel.

Figure F

excelcustomsort-f.jpg

  Assign a macro shortcut for the sort macro.

Before running the macro, sort the data set by the EntryID values. Then, press Ctrl+S to run the macro. The results are the same as the manual two-column sort preformed earlier. It doesn’t matter what cell is selected when you run the macro because the cell references and ranges are explicit.

When to use them

In some cases, the macro might be overkill. If you run only the one sort, you can press Alt-D-S to rerun it over and over. But the fact that you might need keyboard shortcuts does imply that you’re frequently changing the sort. However, it could also mean that you’re deleting or adding records, or modifying values. If it’s the former, convert the data range to a Table range and use the commented line that references the Table and comment out the data range reference statement in the VBA procedure. That way, you can change the number of rows without modifying the macro to accommodate those changes.

You can add the macro to a group tab or to the QAT. When using the later, you can use the Alt key to run the macro using Alt+N, where N is an integer that identifies the macro’s position on the QAT. For example, if it’s the first option, you’d press Alt+1. If it’s the third, you’d press Alt+3, and so on.

To learn how to do either, read How to add Office macros to the QAT toolbar for quick access.

http://www.techrepublic.com/

Microsoft Weekly Newsletter

Be your company’s Microsoft insider by reading these Windows and Office tips, tricks, and cheat sheets.
Delivered Mondays and Wednesdays



Sign up today

Also see

[ad_2]

Source link

Share196Tweet123Share49
admin

admin

  • Trending
  • Comments
  • Latest

Rolex Testimonee Martin Scorsese on the methods of Cinematic Legends

November 23, 2020

Read Trent Reznors Rock Hall Induction Speech for Nine Inch Nails

November 7, 2020

Alex Trebek, Longtime ‘Jeopardy!’ Host, Dead at 80

November 8, 2020

Business booms for lawncare service started by three Saginaw boys | News

0

Judd Apatow, Wanda Sykes to Perform ‘Laughter in Lockdown’ Fundraiser

0

COVID-19 Has Killed More Than 100,000 Americans

0

Business booms for lawncare service started by three Saginaw boys | News

August 2, 2021

MSP seizes more than 1,200 marijuana plants from Carrolton Twp. home | News

August 2, 2021

The Hour Glass and Rolex: Partners in Time

August 2, 2021
10Newz

Copyright © 2017 10Newz.

Navigate Site

  • About
  • Contact
  • DMCA Notice
  • Disclosure Policy
  • Privacy Policy
  • Terms Of Service

No Result
View All Result
  • Home
  • General News
    • Politics
    • Business
    • World
    • Science
  • Entertainment
    • Gaming
    • Music
    • Movie
    • Sports
  • Tech
    • Apps
    • Gear
    • Mobile
    • Startup
  • Lifestyle
    • Food
    • Fashion
    • Health
    • Travel

Copyright © 2017 10Newz.

Login to your account below

Forgotten Password?

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In