Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

What's the best way to sort mulitple columns

39 views
Skip to first unread message

del

unread,
Mar 24, 2001, 11:08:56 AM3/24/01
to
I have the range ("a2:g100") and I want to sort each columns
separately rather than using a key

what's the best way to do this >
Thanks - Del

Tom Ogilvy

unread,
Mar 24, 2001, 12:36:04 PM3/24/01
to
Sub sortEachColumn()
Dim col As Range
For Each col In Range("a2:g100").Columns
col.Sort key1:=col, Order1:=xlAscending
Next
End Sub

--
Regards,
Tom Ogilvy

del <sea...@XXXnew-ark.co.uk> wrote in message
news:3abcc59...@news.btinternet.com...

David McRitchie

unread,
Mar 24, 2001, 1:10:10 PM3/24/01
to
Tom's will sort all data for each column separately for
columns A through G regardless of whether
range is A2:G100, A3:G4

Just for comparison and a more literal interpretation:
This variation will only affect data within the selection
area, sorting each column individually.

Sub sortEachColumn2()
Dim col As Range
' --- Range("a2:g100").Select
For Each col In Selection.Columns
Intersect(col, Selection, ActiveSheet.UsedRange). _


Sort key1:=col, Order1:=xlAscending
Next
End Sub

"Tom Ogilvy" <twog...@email.msn.com> wrote


> Sub sortEachColumn()
> Dim col As Range
> For Each col In Range("a2:g100").Columns
> col.Sort key1:=col, Order1:=xlAscending
> Next
> End Sub
>

0 new messages