Sort by Row "headers" instead of column headers

bds

Board Regular
Joined
Jul 7, 2007
Messages
84
I have info arranged on a sheet so the categories go from left to right in row 1 and then the info relevant to each runs down the page (instead of the more typical way of headers in the top row). This puts my "headers" in column A and I want to sort the data alphabetically based on the word typed in row 1. The Data, Sort option doesn't give me a way to sort alphabetically based on the first row of data. Is there a way to do this?
 

Some videos you may like

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

QuietRiot

Well-known Member
Joined
May 18, 2007
Messages
1,077
you cant just select all cells then sort column A

this would sort by row by column A
 

bds

Board Regular
Joined
Jul 7, 2007
Messages
84
That's what I found as well.

So, how do I sort so the info in each column stays connected with the other info in the column - I just want to arrange the columns alphabetically across the top.

Is this something that can't be done?
 

dcardno

Well-known Member
Joined
Nov 20, 2002
Messages
534
Office Version
  1. 2013
Platform
  1. Windows
You can sort left-to-right, as well as top-to-bottom. In the Data | Sort dialogue, click on "options" at the bottom left. It will bring up a dialoge box with two radio buttons - one for Top / Bottom selected, and one for Left / Right. Click on the Left / Right button, and then "Okay" and make the rest of yoiur sort selections normally. You may have to fiddle a bit to make sure the right range is selected - Excel seems to get a little confused about what is a header and what isn't in this situation...
 

bds

Board Regular
Joined
Jul 7, 2007
Messages
84

ADVERTISEMENT

Perfect! - thank you - thought I had read you could do it but couldn't figure out where and couldn't find search words that gave me a relevant result.
 

Datsmart

Well-known Member
Joined
Jun 19, 2003
Messages
7,985
If you want to keep Row "Header" Titles, this code will SORT your data by Copying it to a temp worksheet, transpose it, Sort it, then Transpose it back.
Code:
Sub SORTByRow()
Dim CurSht As String
    CurSht = ActiveSheet.Name
'Create Temp WorkSheet
    Sheets.Add.Name = "Temp1"

'Transpose Range to Temp worksheet
    Sheets(CurSht).Range("A1").CurrentRegion.Copy
    Sheets("Temp1").Range("A1").PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=True

'SORT by Column A
    Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal

'Transpose back to original worksheet
    Selection.Copy
    Sheets(CurSht).Range("A1").PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=True
    Sheets(CurSht).Select

'Delete Temp WorkSheet
    Application.DisplayAlerts = False
        Sheets("Temp1").Delete
    Application.DisplayAlerts = True
End Sub
 

bds

Board Regular
Joined
Jul 7, 2007
Messages
84
If you want to keep Row "Header" Titles, this code will SORT your data by Copying it to a temp worksheet, transpose it, Sort it, then Transpose it back

Thank you very much.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,656
Messages
5,597,390
Members
414,141
Latest member
Joey_T92

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top