Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / May 2008

Tip: Looking for answers? Try searching our database.

sort entire range with exception of last row

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
joemeshuggah - 19 May 2008 21:17 GMT
is there a snipet of vba code that could be used to sort 3 columns of
variable length with the exception of the last row (last row used for totals).

The column range is a:k (rows, again, are variable).  I am looking to sort
in this order:
column k descending
column j descending
column a ascending
JW - 19 May 2008 21:28 GMT
On May 19, 4:17 pm, joemeshuggah
<joemeshug...@discussions.microsoft.com> wrote:
> is there a snipet of vba code that could be used to sort 3 columns of
> variable length with the exception of the last row (last row used for totals).
[quoted text clipped - 4 lines]
> column j descending
> column a ascending

Give this a shot.  This is using column A to determine the last row.
Change is needed.

Sub try()
   Dim lRow As Long
   lRow = Cells(Rows.Count, "A").End(xlUp).Row - 1
   Range("A2:K" & lRow).Sort _
       Key1:=Range("K2"), Order1:=xlDescending, _
       Key2:=Range("J2"), Order2:=xlDescending, _
       Key3:=Range("A2"), Order3:=xlAscending
End Sub
joemeshuggah - 21 May 2008 19:15 GMT
Excellent....Thank you so much!!!

> On May 19, 4:17 pm, joemeshuggah
> <joemeshug...@discussions.microsoft.com> wrote:
[quoted text clipped - 18 lines]
>         Key3:=Range("A2"), Order3:=xlAscending
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.