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?
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
you cant just select all cells then sort column A

this would sort by row by column A
 
Upvote 0
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?
 
Upvote 0
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...
 
Upvote 0
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.
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,222,173
Messages
6,164,388
Members
451,888
Latest member
OhSheet

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
Back
Top