+ Reply to Thread
Results 1 to 23 of 23

Custom Sort not working

  1. #1
    Forum Contributor
    Join Date
    08-12-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    163

    Custom Sort not working

    I'm trying to sort a range of data by a custom list the code is below. i first create a customlist then sort a range based on that list

    Please Login or Register  to view this content.
    i took this code from another post and changed it up to fit what i need its tell me Run-time error '438': Object doesn't support this property or method. when stepping through this line
    Please Login or Register  to view this content.
    i dont really understand how that line works so i dont know whats wrong with it.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Custom Sort not working

    That line would never work, Sheets aren't a propert of Sheets.

    In fact there are other parts of the code that don't make sense either.

    For example, what's supposed to be happening here?
    Please Login or Register  to view this content.
    It looks like that line of code is trying to set the value of a sheet which isn't possible.

    Does this work?
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    08-12-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    163

    Re: Custom Sort not working

    thank you

    i didnt think that was right

    your code runs but i think my custom list isnt right i have words and numbers in a specific order, when i look at the custom list the numbers r not showing up

    example of part of the custom list

    Roadway
    203
    204
    205
    207
    Pavement
    202
    541

    do you know why its not storing the customlist right?

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Custom Sort not working

    Can you upload an example workbook?

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  5. #5
    Forum Contributor
    Join Date
    08-12-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    163

    Re: Custom Sort not working

    okay i attached an example workbook with just a small amount of data and next to it I show how i want it to sort
    Attached Files Attached Files

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Custom Sort not working

    Your list has numbers, which Excel will not import into a custom list. Select the list, Data > Text to columns, Delimited, Next, Next, tick Text, Finish.

    Now the numbers are text (which you can see because they are now left justified), and the table sorts as you wish.
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Forum Contributor
    Join Date
    08-12-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    163

    Re: Custom Sort not working

    changed the numbers to text and the customlist is correct but when i run the marco it puts the words under the numbers

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Custom Sort not working

    Just curious, but why do you have Roadway and Pavement in a column of numbers?

  9. #9
    Forum Contributor
    Join Date
    08-12-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    163

    Re: Custom Sort not working

    its for projects im pulling in data from subsummary sheets to a general summary sheet the ID column are item numbers and they go under certain catagories. there are thousands of item numbers but the first three numbers can tell which catagory it should go under so all the numbers under roadway go with the roadway catagory. there are more catagories then roadway and pavement im just simplifing for the code.

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Custom Sort not working

    Why not have the category in another column?

  11. #11
    Forum Contributor
    Join Date
    08-12-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    163

    Re: Custom Sort not working

    it works when i manually do a sort and click on custom sort it comes up with a box saying something about numbers being represented at text and u can click what you want to do.
    im assuming that is what is messing up the macro.
    if anyone knows how to fix that

    I quick fix would to just add a letter to all the numbers

    thanks for the help ill mark this as solved

  12. #12
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Custom Sort not working

    This worked for me, after converting the numbers to text as I described:

    Please Login or Register  to view this content.
    Last edited by shg; 06-19-2013 at 12:58 PM.

  13. #13
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Custom Sort not working

    I think you might be missing a setting in the sort.

  14. #14
    Forum Contributor
    Join Date
    08-12-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    163

    Re: Custom Sort not working

    thanks shg that code worked

  15. #15
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Custom Sort not working

    I find it exceeding odd that you need the +1. Norie?

  16. #16
    Forum Contributor
    Join Date
    08-12-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    163

    Re: Custom Sort not working

    when i add that code everytime i try to save it excel crashes

  17. #17
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Custom Sort not working

    Where have you put the code?

    In the sample workbook it was in the ThisWorkbook module, it should be in a standard module.

  18. #18
    Forum Contributor
    Join Date
    08-12-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    163

    Re: Custom Sort not working

    i opened the VBA and double click thisworkbook and put the code in there

    should it be going somewhere else

  19. #19
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Custom Sort not working

    From the VBE, Insert > Module. Put the code there.

  20. #20
    Forum Contributor
    Join Date
    08-12-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    163

    Re: Custom Sort not working

    i tried that and the same thing happened. i have other macros in that thisworkbook section and that saves and works fine

    i just tried adding the macro and saving it and it saves. something is going on after I run that Sort macro that causes it to crash when saving. I assume its got something to do with the customlist

    you know anything about this

  21. #21
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Custom Sort not working

    Moving the code to a standard module doesn't address the crashing issue -- it's just where the code belongs.

    Try adding this line just before the DeleteCustomList line:

    Please Login or Register  to view this content.

  22. #22
    Forum Contributor
    Join Date
    08-12-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    163

    Re: Custom Sort not working

    that worked thank you so much

  23. #23
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Custom Sort not working

    You're welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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