Sort code works in column H but not when column is (SOLVED)

  • I have two columns with auto mileage numbers. Each has a different set of numbers. We have not been sorting on column G. I've been sorting column H highest mileage to lowest.
    This works perfectly, for example:


    Column H after sort


    Mileage
    250,000
    200,000
    185,000
    101,000


    But if I change the letter "h" to "g" in the code the sort puts a particular number in the top cell, the same number every time. The rest of the numbers under it appear to have sorted properly.

    Column G
    after sort


    Mileage
    101,000
    250,000
    200,000
    185,000


    Code that works:

    Code
    Selection.Sort Key1:=Range("h5"), Order1:=xlDescending, Header:=xlGuess, _
            OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
            DataOption1:=xlSortTextAsNumbers


    Code that doesn't work:

    Code
    Selection.Sort Key1:=Range("g5"), Order1:=xlDescending, Header:=xlGuess, _
            OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
            DataOption1:=xlSortTextAsNumbers


    I've tried changing the formatting and checked to make sure the number that keeps coming up at the top doesn't have a single quote , but I am really stumped. I'd appreciate any help you can give me. I need to wrap this project up as soon as I can. Thanks!

  • Re: Sort code works in column H but not when column is changed to G (SOLVED)


    Sorry all. I went back and re-keyed the number in column G I was having trouble with and now it works fine.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!