Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default sort entire range with exception of last row

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default sort entire range with exception of last row

On May 19, 4:17*pm, joemeshuggah
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).

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


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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default sort entire range with exception of last row

Excellent....Thank you so much!!!

"JW" wrote:

On May 19, 4:17 pm, joemeshuggah
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).

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


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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to sort entire spreadsheet by one column sort jbclem Excel Discussion (Misc queries) 6 April 2nd 23 08:06 PM
Exception from HRESULT: 0x800A03EC while binding values to a range Jignesh Gandhi[_2_] Excel Programming 0 February 26th 07 07:36 PM
How can I sort one column and have the entire row sort. (binding) Blue Excel Worksheet Functions 10 November 13th 05 07:09 PM
Excel.Range.Name gives error an exception [email protected] Excel Discussion (Misc queries) 2 August 23rd 05 08:14 AM
Excel.Range.Name gives error an exception [email protected] Excel Programming 2 August 23rd 05 08:14 AM


All times are GMT +1. The time now is 07:40 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"