Hi all,
I'm trying to get the correct syntax for identifying the range in a variable sized table on sorting. The line using a fixed range reference - Range("E2:E296") - works but doesn't cater for the changing table size. I've tried syntax in the line above to correct this but it's giving me an error. Can anyone advise what the correct syntax is please,
thanks, Neil
Sub a1()
With ActiveWorkbook.Worksheets("Analysis Sheet").Sort
.SortFields.Clear
.SortFields.Add Key:=Range("d2", ActiveCell.End(xlDown)).Address,
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.SortFields.Add Key:=Range("E2:E296"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.SetRange DataRange
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Bookmarks