Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   VBA Help required, issues with sorting. (http://www.go4expert.com/forums/vba-help-required-issues-sorting-t15446/)

Naigan 9Dec2008 00:06

VBA Help required, issues with sorting.
Hey guys, i'm having a problem here, i'm trying to create a macro to sort a range of data, I can get it to select the whole table easily, but the problem is after I create the macro, if I wanted to add further data to it, it misses out that data when doing the sorting process.. If anyone has any recommendations i'd appreciate it, here's the code...


    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlToRight)).Select
    ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("M2:M18") _
        , SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Sheet1").Sort
        .SetRange Range("A1:M18")
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
    End With

All times are GMT +5.5. The time now is 22:08.