Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    May 2001
    Location
    MIA (takittodahous), Florida, USA
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Sort is re-writing fields (Excel2002)

    Hi all,

    I'm having an interesting experience with the following code:

    Range("A1:H10000").Sort Key1:=Range("C2"), Order1:=xlAscending, Key2:=Range _
    ("D2"), Order2:=xlDescending, Key3:=Range("F2"), Order3:=xlDescending, _
    Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
    xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, _
    DataOption3:=xlSortNormal

    It writes over the top 9 rows of columns B and C with the column header.... Any ideas?

    Thank you!

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Sort is re-writing fields (Excel2002)

    Any chance that the column headers are repeated somewhere in your data?

    Does it help if you replace Header:=xlGuess by Header:=xlYes?

  3. #3
    Star Lounger
    Join Date
    May 2001
    Location
    MIA (takittodahous), Florida, USA
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Sort is re-writing fields (Excel2002)

    Nope on both counts... hmm. I'm breaking the macro before the sort and everything is fine in the data - and this time I changed the xlGuess to xlYes, as you mentioned. But I still get the same result. Everything is fine - up until the sort - and then the data gets wiped out.... and only on those two columns - weird!

    Are there any known glitches in SP2 for the sort function - I'm gonna check the Knowledge Base....

    Thanks,

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Sort is re-writing fields (Excel2002)

    Good luck with the KB. I don't have other ideas - your code looks OK. <img src=/S/sorry.gif border=0 alt=sorry width=15 height=15>

  5. #5
    Star Lounger
    Join Date
    May 2001
    Location
    MIA (takittodahous), Florida, USA
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Sort is re-writing fields (Excel2002)

    Thanks again for your help. I was really hoping xlYes would have fixed it... hehe.

    Have a good one

  6. #6
    Star Lounger
    Join Date
    May 2001
    Location
    MIA (takittodahous), Florida, USA
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Sort is re-writing fields (Excel2002)

    Aaah HAH!

    The problem lay in a previous portion of the macro - the data was as a cell reference instead of text. Therefore, it was showing exactly what it shoud. Once I cleaned up the routine, that cured it....

    Thanks for your input - definitely aimed me in the direction of the problem.

    ;-]]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •