Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Sort function question.

Status
Not open for further replies.

aurbo

Technical User
Sep 2, 2002
7
CA
How would you sort entire rows alphabetically based on the values of Column B ?

I must be missing something very simple, my range of data gets completely messed up when I try. only the selected column will sort and the rest of the range does not.

Steve






 
Maybe I'm missing something too. You mean this?

Code:
Cells.Select
    Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlGuess, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal

I think this is what you're looking for ???
skywaz
 
I think SkyWaz's solution only sorts the values in the B column and leaves all the other colums in there original order. I think it's Range("A..F") or something similar. I've found one of the best ways to get the correct syntax for these types of things is to record a macro while I'm doing it by mouse and I can see that it does what I want, then go to Tools and Edit the Macro and I can see what code was produced to get the results I want. Then use the code where I need it. Good Luck!

Leslie
landrews@metrocourt.state.nm.us

SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned
 
Nope:
Cells.Select
gives the game away - ALL cells will be sorted based on B although if there is a header row, I believe you need to use B2 rather than B1 Rgds
~Geoff~
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top