Results 1 to 4 of 4
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    WHY!!! (2000 sr 1)

    ... I set the ordering A7 to X from index Q and the all record not is ordered ascending correctly...

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: WHY!!! (2000 sr 1)

    The numbers are not all seen as numbers, they are stored as text and thus sorted as if they are text.
    Select column Q, press F5 (goto), special, select the constants option and only check "text". You'll see that part of the cells will be selected. Excel has those cells formatted as text.

    Now select column Q again, choose Data, text to columns (Dati, Testo in colonne...), click Finish.

    Now if you repeat the first step above (F5), I expect no cells with numbers are found, since you have just converted them to numbers.
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: WHY!!! (2000 sr 1)

    WOH!!!!!!!!!!! It wok!
    TKS.

    But 2 dubts,

    I take this data from a text file with:

    var_NRASS = Trim(Mid(RIGA, 45, 10))

    and order this shett with:

    Sub ORD_ASS_TOTALE()
    Sheets("L0785_TOTALE").Select
    Range("A7:X7").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Sort Key1:=Range("Q7"), Order1:=xlAscending, Header:=xlGuess, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
    End Sub

    is possible to set in automatic your suggestion in the first or second case?

  4. #4
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: WHY!!! (2000 sr 1)

    You could define your variable (var_NRASS) as double so it will try to be a number

    or even use something like
    var_NRASS = val(Trim(Mid(RIGA, 45, 10)))

    to get a number, rather than text.

    You can also use Jan's technique in code: you can use the macrorecorder to get the code objects, then generalize it.

    Steve

Posting Permissions

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