+ Reply to Thread
Results 1 to 13 of 13

Developing a Sorting Macro

  1. #1
    Registered User
    Join Date
    12-11-2013
    Location
    new york,ny
    MS-Off Ver
    Excel 2010
    Posts
    40

    Developing a Sorting Macro

    Hello All,

    I am having an issue building a macro that will allow me to chronologically arrange these ranges by season. The sort function does not work here so I was wondering if anyone had input on how to do this not for this document but for a variety of sheets within a workbook and all different placements on the sheet.

    Thanks! Attached is an example of the work book with a few work sheets.
    Attached Files Attached Files

  2. #2
    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: Developing a Sorting Macro

    Hello joker25,

    It does not look like you have included any before and after examples of the sort. Which sheets will the sort apply to?
    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!)

  3. #3
    Registered User
    Join Date
    12-11-2013
    Location
    new york,ny
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Developing a Sorting Macro

    My apologies looks like this one was already manually sorted. Here's an example of a before and after.
    Attached Files Attached Files

  4. #4
    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: Developing a Sorting Macro

    Hello joker25,

    Thanks for the updated workbook. It makes perfect sense now. Excel and VBA sort text by the character codes which is fine for letters but numbers don't sort according to human logic. As long as each sheets layout is the same as what you posted, I can create a macro to run on any sheet in this format.

  5. #5
    Registered User
    Join Date
    12-11-2013
    Location
    new york,ny
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Developing a Sorting Macro

    That's great news! Yes the pages are layed out the same but the number of rows per season will vary.

    I appreciate your help Leith

  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: Developing a Sorting Macro

    Hello joker25,

    Excel always seems to act erratically or crash at the worst possible time. The attached workbook has a button on it to run the macro. The macro gathers data from the "Before" sheet and then copies the sorted ranges over to the "After" worksheet.

    Unfortunately, I can not do a sort in place. The macro could be modified to use a single destination sheet for the sorted ranges and copy the sorted ranges back to the original sheet. That is, if you need to sort in place.
    Attached Files Attached Files

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Developing a Sorting Macro

    No use of extra sheet.
    Try the attached.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    12-11-2013
    Location
    new york,ny
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Developing a Sorting Macro

    Can these sorts be applied to the entire workbook for multiple sheets or only the one sheet?

  9. #9
    Forum Contributor
    Join Date
    10-01-2013
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    136

    Re: Developing a Sorting Macro

    @ Jindon...your code is very well written

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Developing a Sorting Macro

    Quote Originally Posted by vnzerem View Post
    @ Jindon...your code is very well written
    Thanks...........

  11. #11
    Forum Contributor
    Join Date
    10-01-2013
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    136

    Re: Developing a Sorting Macro

    @Jindon...in your code, can you explain to me the lines in red? I will like to fully understand your reasons especially the "CreateObject(System.collections)" Thanks

    Please Login or Register  to view this content.

  12. #12
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Developing a Sorting Macro

    @ Jindon, in case you were worried about vnzerem's asking question's on another member's thread, if they are just asking for explanation of code/formula or formula that has been provided, I think it would be OK to explain.

    If it develops into asking for chamges, then a new thread would be required
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Developing a Sorting Macro

    Thanks.
    vnzerem has opened a new thread already, so I replied to his/her thread.

+ 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. [SOLVED] Developing a macro to locate a keyword, delete that row and all rows below
    By Student1990 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-09-2013, 03:00 PM
  2. Developing a "Search" or "Find" Macro/ VBA Program
    By SamBevis in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-27-2013, 09:44 PM
  3. Need Help in Developing Macros
    By djfifita in forum Excel General
    Replies: 3
    Last Post: 09-28-2011, 04:34 AM
  4. Bypass Beforesave Macro while developing
    By MarkH000 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-01-2011, 05:13 PM
  5. [SOLVED] Developing macro event to allow multiple choices on drop down menu
    By Brendan in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-06-2006, 11:35 AM

Tags for this Thread

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