Hi,
I'm preparing a template for sorting information which we get from a report downloaded from our database. The report is always of a different length and my sorting buttons don't always work (if the report is to short or too long). I've created three different macros for sorting, they are the same just sort by a different column:
Sub Sort_by_Invoice()
'
' Sort_by_Invoice
'
'
Range("A2:K2").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Worksheets("Claim").SORT.SortFields.Clear
ActiveWorkbook.Worksheets("Claim").SORT.SortFields.Add Key:=Range("D3:D1530") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Claim").SORT
.SetRange Range("A2:K1530")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
The problem is, the selection button doesn't work the way I want. When I created the macro I highlighted the top row and then pressed Ctrl+Shift+down arrow thinking this would work for the different lengths of the report. Well, it doesn't work. The sorting is all over the place.
Now, I was thinking maybe I could use a Do...Until command with something saying until the active cell at the bottom of the report is empty. But I am not sure how to write the code so that it works.
Can anyone help, please?
Bookmarks