help with sorting

Simi

New member
Joined
Feb 10, 2012
Messages
190
Reaction score
0
Points
0
Location
Utah, USA
Excel Version(s)
Version 2002 Build 12527.20194
I am trying to sort an unpredictable size of data on a form that I use.
I always start on the same row,column but it will expand to an unknown size.
I have used this as a hardcode for now but I have to modify the cells every time I run.
ActiveSheet.Range("AS2:" & "AZ" & rowcnt).Sort Key1:=ActiveSheet.Range("AU2"), Order1:=xlDescending, Key2:=ActiveSheet.Range("AV2")

I will always start my range in AS2 and will always sort by AU2 and AV2.
I am trying to get a use of a variable for AZ in this example, sometimes it is AV and I have had as many as BE now.

I have tried using the following but get an error. As a side note rowcnt is calculated before this code.
Code:
With ActiveSheet
    .Range(Cells(2, 45), Cells(rowcnt, 52)).Sort Key1:=ActiveSheet.Range(Cells(2, 47)), Order1:=xlDescending, Key2:=ActiveSheet.Range(Cells(2, 48))
End With

Any help is greatly appreciated.

Thank you

Simi
 
Last edited:
Dive into the VBEditor's helpfiles, lemma 'currentregion'
 
Back
Top