![]() |
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 |
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 |
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 |
All times are GMT +1. The time now is 06:43 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com