I'm trying to write a macro which will data sort a dynamic range. The number of columns will always be the same (A:N) but the number of rows will change.
So I want to start at row 4 and sort all data from here down, based on the contents of column N. I don't have any headers.
Here is what I managed to record but I'm not sure how this should be changed to fit my range?
Many thanks in advanceSub TestMacro() Rows("4:274").Select ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("N4:N274") _ , SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal With ActiveWorkbook.Worksheets("Sheet1").Sort .SetRange Range("A4:N274") .Header = xlGuess .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With End Sub