# sorting in excel - how do you do this?

**URL:** <https://boards.straightdope.com/t/sorting-in-excel-how-do-you-do-this/546075>\
**Category:** Factual Questions\
**Created:** [July 9, 2010, 9:48am UTC](https://boards.straightdope.com/t/sorting-in-excel-how-do-you-do-this/546075 "2010-07-09T09:48:00Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![crypto](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@crypto](https://boards.straightdope.com/u/crypto)\
**Post date:** [July 9, 2010, 9:48am UTC](https://boards.straightdope.com/t/sorting-in-excel-how-do-you-do-this/546075/1 "2010-07-09T09:48:00Z")

</div>

I have an excel spread sheet with the last names of people in one column, and their corresponding first names in the next column. Is there any way to connect these two columns, so when I sort the last names in alphabetical order their first names will move with them?

Right now, when I sort the last names in column a, the first names in column b stay put. I’ve tried selecting both columns, but the sort result is not correct for the first names.

Is this possible?

---

<div class="post-metadata">

**Author:** ![ColdPhoenix](https://avatars.discourse-cdn.com/v4/letter/c/6bbea6/32.png) [@ColdPhoenix](https://boards.straightdope.com/u/ColdPhoenix)\
**Post date:** [July 9, 2010, 9:57am UTC](https://boards.straightdope.com/t/sorting-in-excel-how-do-you-do-this/546075/2 "2010-07-09T09:57:24Z")

</div>

> [@Stink Fish Pot](#):
>
> I’ve tried selecting both columns, but the sort result is not correct for the first names.

In what way is it not correct for first names?

Selecting both columns, going to Data\>Sort should then give you a box where you can sort by surnames and then by first names if that’s what you want.

---

<div class="post-metadata">

**Author:** ![crypto](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@crypto](https://boards.straightdope.com/u/crypto)\
**Post date:** [July 9, 2010, 10:05am UTC](https://boards.straightdope.com/t/sorting-in-excel-how-do-you-do-this/546075/3 "2010-07-09T10:05:38Z")

</div>

> [@ColdPhoenix](#):
>
> In what way is it not correct for first names?
> 
> Selecting both columns, going to Data\>Sort should then give you a box where you can sort by surnames and then by first names if that’s what you want.

I don’t know what happens, but the correct first name doesn’t go with its corresponding last name.

for example, in column B, I have Smith.

in column C, I have John

When I sort these two alphabetically, I’d like the entry Smith John show up in columns b and c in the correct spot in the alphabetically sorted list.

---

<div class="post-metadata">

**Author:** ![sandra\_nz](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@sandra\_nz](https://boards.straightdope.com/u/sandra_nz)\
**Post date:** [July 9, 2010, 10:15am UTC](https://boards.straightdope.com/t/sorting-in-excel-how-do-you-do-this/546075/4 "2010-07-09T10:15:27Z")

</div>

Usually this happens because you have only highlighted the one column, so Excel interprets that as “sort this column only, ignore the rest”.

To be safe, you should either click one cell in the worksheet and go to the Sort menu, or select the entire worksheet before going to the Sort menu.

Is that what you’re currently doing? Do your columns have headers?

---

<div class="post-metadata">

**Author:** ![One\_And\_Only\_Wanderers](https://avatars.discourse-cdn.com/v4/letter/o/838e76/32.png) [@One\_And\_Only\_Wanderers](https://boards.straightdope.com/u/One_And_Only_Wanderers)\
**Post date:** [July 9, 2010, 10:15am UTC](https://boards.straightdope.com/t/sorting-in-excel-how-do-you-do-this/546075/5 "2010-07-09T10:15:50Z")

</div>

as previously said highlight both columns when sorting on column a, and the entries in a & b should retain their relationship to each other

---

<div class="post-metadata">

**Author:** ![Richard\_Pearse](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/richard_pearse/32/13144_2.png) [@Richard\_Pearse](https://boards.straightdope.com/u/Richard_Pearse)\
**Post date:** [July 9, 2010, 10:46am UTC](https://boards.straightdope.com/t/sorting-in-excel-how-do-you-do-this/546075/6 "2010-07-09T10:46:58Z")

</div>

Make sure you tell it you don’t have a header row, or if it does have a header row, make sure it is included in the selection. If it thinks you have a header row and you don’t it will not sort the first row.

---

<div class="post-metadata">

**Author:** ![canadiankorean](https://avatars.discourse-cdn.com/v4/letter/c/2bfe46/32.png) [@canadiankorean](https://boards.straightdope.com/u/canadiankorean)\
**Post date:** [July 9, 2010, 2:13pm UTC](https://boards.straightdope.com/t/sorting-in-excel-how-do-you-do-this/546075/7 "2010-07-09T14:13:33Z")

</div>

Usually before sorting, I click on the top left spot in the spreadsheet. Beside the column.

This will move everything in sort.

---

<div class="post-metadata">

**Author:** ![crypto](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@crypto](https://boards.straightdope.com/u/crypto)\
**Post date:** [July 9, 2010, 7:30pm UTC](https://boards.straightdope.com/t/sorting-in-excel-how-do-you-do-this/546075/8 "2010-07-09T19:30:25Z")

</div>

Thank you, all!

I was not including everything in the selection before sorting (I thought I was). When I did so, the sort worked as expected.

---

<div class="post-metadata">

**Author:** ![KneadToKnow](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/kneadtoknow/32/3999_2.png) [@KneadToKnow](https://boards.straightdope.com/u/KneadToKnow)\
**Post date:** [July 9, 2010, 7:37pm UTC](https://boards.straightdope.com/t/sorting-in-excel-how-do-you-do-this/546075/9 "2010-07-09T19:37:43Z")

</div>

The other thing is to make sure you’re only sorting the column you want to sort. I had somebody once who was doing essentially the same sort you are doing, but he set it to sort by last name, then by first name. Sure, the _Henreich_s and _Ludovic_s were fine, but he really messed up his _Smith_s and _Jones_es.

---

<div class="post-metadata">

**Author:** ![Munch](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/munch/32/5281_2.png) [@Munch](https://boards.straightdope.com/u/Munch)\
**Post date:** [July 9, 2010, 8:28pm UTC](https://boards.straightdope.com/t/sorting-in-excel-how-do-you-do-this/546075/10 "2010-07-09T20:28:18Z")

</div>

For extra fanciness, select all the columns with data in them, and go to Data-\>Filter-\>AutoFilter. Now you can sort by whatever you want without having to go and select all the columns every time you want to move things around.
