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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sorting individual columns. 1

Status
Not open for further replies.

everest

Technical User
Oct 2, 2002
21
0
0
US
Hi,

I have an excel question regarding sorting individual columns.

I have data in such a format

Iron Lead Zinc
0.5 0.3
0.2 0.1
0.2 0.1 0.2

And I would like it to be in this format

Iron Lead Zinc
0.5 0.3 0.2
0.2 0.2 0.1
0.1


Normally, I would just highlight each column and click the sort ascending/descending and it would be done. It's just that I have to do it for several hundred or maybe over a thousand different chemicals. I've tried recording a macro, but with no success. Reason for getting it into this format is because an analysis addin needs the data in this format, no blank spaces.

Any help would be appreciated. Thanks.

Everest


 
How about something like this:-

Sub Sort()

For Each Column In ActiveSheet.UsedRange.Columns

Column.Sort Key1:=Column, Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Next Column

End Sub

Regards
Ken..................
 
Nice code.

What I don't inderstand is why the relationship of each measurement is discarded so as to work within the analysis addin. One would assume that when iron is .5 the measurement of null for zinc is relevant??

Anyway, I liked the
For Each Column In ActiveSheet.UsedRange.Columns

I'll save that for a rainy day. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top