+ Reply to Thread
Results 1 to 6 of 6

Using sort descending in VBA

  1. #1
    Forum Contributor
    Join Date
    03-18-2009
    Location
    Tokyo, Japan
    MS-Off Ver
    Excel 2003
    Posts
    104

    Using sort descending in VBA

    I have some sheets which I would like to loop through and use sort descending on column S, would somebody help me out with the code to do so? I actually have the looping code already, I just need the sort descending bit.
    Last edited by eonizuka; 01-05-2010 at 02:46 PM.

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

    Re: Using sort descending in VBA

    Try recording a macro?
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor
    Join Date
    03-18-2009
    Location
    Tokyo, Japan
    MS-Off Ver
    Excel 2003
    Posts
    104

    Re: Using sort descending in VBA

    I used the macro recorder and inserted the recorded code into the macro I'm using. I'm getting an error on the .sort section of the code stating "method or data member" not found. I'm not sure of the syntax to point to the current worksheet either. Thanks for your patience with me on this. Edit: I removed the (s) from the worksheet object and the code runs but it isn't sorting the data.

    Please Login or Register  to view this content.
    Last edited by eonizuka; 01-05-2010 at 01:15 PM.

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

    Re: Using sort descending in VBA

    Untested (I edited this in 2003). Your references were not qualified to the worksheet. The most important line in the code is the very first one.
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    03-18-2009
    Location
    Tokyo, Japan
    MS-Off Ver
    Excel 2003
    Posts
    104

    Re: Using sort descending in VBA

    The code isn't sorting the data; I have attached a sample workbook with the data and code. I slightly modified it for use with just this one sheet.
    Attached Files Attached Files

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Using sort descending in VBA

    Konnichi wa Eonizuka san,

    Akemashite omedetō gozaimasu!

    I can't edit Excel 2007 files, only read them. So, the modifications to your macro are untested, but it should work. Here is the modified macro.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ 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