+ Reply to Thread
Results 1 to 4 of 4

Unusal Range.Sort vba error

  1. #1
    Forum Contributor
    Join Date
    03-17-2013
    Location
    USA, IL
    MS-Off Ver
    Excel 2010
    Posts
    121

    Post Unusal Range.Sort vba error

    Hi

    I have a sort vba that sorts specific Range in X but for some odd reason it only sorts less than half of the data in decending order as it shpuld but the rest of the data in the same range doesn't seem to be sorted (data consist of numbers ranging from $0 to ($3000)) in the specified range which most often is not more than 39 rows.
    I am not quite sure what I am doing wrong in my code below. I appreciate your time. Thanks

    Please Login or Register  to view this content.
    Thanks

    Just a side note; the data in column O was Formatted as Currency but when I change it to Numbers it still doesn't solve the issue.

    Thanks.
    Attached Files Attached Files
    Last edited by Pi*; 06-30-2016 at 11:36 PM.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,619

    Re: Unusal Range.Sort vba error

    1) headers shall be xlno not just no
    Please Login or Register  to view this content.
    2) key1 - it is enough to have just first cell, like:
    Please Login or Register  to view this content.
    3) you probably noted that some data is excluded from sorting (rows 54 and 85:92)
    The other shall be sorted descending order (by column O) in each of 3 contignous ranges (rows 14:53, 55:84 and 93:103)
    Of course any other column is not sorted

    Please Login or Register  to view this content.
    Best Regards,

    Kaper

  3. #3
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,619

    Re: Unusal Range.Sort vba error

    PS. to avoid such problems as in 1) add declaration:
    Please Login or Register  to view this content.
    at the very top of the code in module.
    You can force excel to add it automatically to every newly created module by selecting "require variables declaration" in Tools - Options in Visual Basic Editor
    Attached Images Attached Images

  4. #4
    Forum Contributor
    Join Date
    03-17-2013
    Location
    USA, IL
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: Unusal Range.Sort vba error

    Thank you Kaper.
    I started from scratch using the same logic but different worksheet and it works fine now.

    Thank you all for your invaluable assistance and advise.

    Pi*

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Cannot Sort Range VBA - "Unable to get sort property of range class"
    By jkj115 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-13-2015, 04:51 PM
  2. [SOLVED] Sort Macro Run-time error '1004': Application/Object-defined error.
    By sam1212 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-22-2014, 10:05 AM
  3. [SOLVED] Run-time error when trying to sort a range
    By g8r777 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-17-2012, 06:08 PM
  4. sort button - how to sort large range in boxes
    By jw01 in forum Excel General
    Replies: 2
    Last Post: 03-06-2012, 09:35 PM
  5. XL03 Sort error: "Method 'Range' of object '_Worksheet' failed"
    By AdLoki in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-07-2011, 08:23 AM
  6. sort method of range class failed error 1004
    By droberts77uk in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-23-2009, 11:09 PM
  7. [SOLVED] UNUSAL PROBLEM
    By David Harrison in forum Excel General
    Replies: 2
    Last Post: 03-08-2006, 06:40 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1